I have to do </^< a whole lot. So I created a macro: let @w = '</^<Enter' (where Enter is entered via Ctrl+V M).

But when I run it with @w it shifts the cursor down one line - which is NO GOOD because I frequently want to do . a few times. So I modified the macro to be let @w = '</^<Enterk'

But now it shifts the cursor UP one line! Seems you cannot win! How the heck do you do this and keep the cursor on the same line?


1 Answer 1


Try this:

call setreg('w', "</^<\r", 'c')

This issue is explained at :h :let-@:

If the result of {expr1} ends in a <CR> or <NL>, the register will be linewise, otherwise it will be set to characterwise.

:let sets a register ending with CR to linewise; and in a linewise register, a line must always end with C-j (at least on linux).

For more info, see my notes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.