1

I'm trying to make a mapping that inserts an empty line below without moving the cursor and to make this repeatable with repeat.vim. I have modeled this from vimcasts. To get back to the original position after the O/o operation I use mark e. I have the code below in my .vimrc.

Why doesn't the code below work?

 Insert empty line above, repeatable
 nnoremap <silent> <Plug>EmptyLineAbove meO<ESC>`e :call repeat#set("\                      
 <Plug>EmptyLineAbove")<CR>
 nnoremap gO <Plug>EmptyLineAbove
 "Insert empty line below, repeatable
 nnoremap <silent> <Plug>EmptyLineBelow meo<ESC>`e :call repeat#set("\         
 <Plug>EmptyLineBelow")<CR>
 nnoremap go <Plug>EmptyLineBelow
  • Try maybe using nmap instead of nnoremap for gO and go – grodzik Jan 31 '17 at 10:40
  • That fixed it. Could you explain why in an answer to this question? – Andreas Jan 31 '17 at 11:24
  • Also I had to remove the space berfore :call. This moves the cursor one step to the right. – Andreas Jan 31 '17 at 11:25
2

gO and go mappings should be made with nmap instead of nnoremap. nnoremap disallows recursion in mappings or nesting, it's usefull for redefining commands. With nmap Vim scans right side of the mapping further for possible mappings. Read more with :h :nmap and :h :nnoremap.

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.