0
nnoremap <End> <S-A>        " line comment

Pressing End key then produces the desired effect but vim also appends " line comment to the end of the line!

Is there any way to kinda let vim know where nnoremap directive ends?

1

This is a common pitfall. After :map, everything is taken as the right-hand side. I would recommend to place the comment on a separate line:

" line comment
nnoremap <End> <S-A>

But if you really want to stick with the trailing comments, you can employ the default command separation (with |, with in a mapping has to be either escaped \| or written as <Bar>) to append a separate comment "command":

nnoremap <End> <S-A>|        " line comment

PS: Instead of <S-A>, you can simply write A :help key-notation.

2
  • Thanks, @IngoKarkat, using pipe symbol worked! Weird though, escaping the pipe symbol actually breaks the trick for me. Using <Bar> instead of pipe doesn't work either. I use nvim. – arkadyt Jan 19 '19 at 21:22
  • 1
    Yes, <Bar> or \| is for when you want to include the remainder in the mapping, which here is not what you want, so you have to use | here. But it's more common the other way around, that's why I mentioned that as well. – Ingo Karkat Jan 20 '19 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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