How do you yank X number of characters in vim?

Yank supports standard movement commands. Use y5l (<- that’s a lowercase L)

And if you want to yank 5 characters backwards, use y5h.

Now, if you’re feeling really lazy, remap this particular sequence to a key-combination, like so:

:nnoremap <C-l> y5l

In this case, “yank 5 to the right” gets mapped to Ctrl+L (lowercase L).


If you’d like, you can also use Space instead of L to yank characters in the forward direction (examples: ySpace for a single character or 5ySpace for 5). Some people may find it to be quicker or easier than hitting L.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)