Due to working in an environment with no clipboard support I have the following line in my .vimrc:

nmap <F12> :set invnumber<CR> <bar> :set invpaste<CR>

Oddly enough, this works for some files I open, but any other file (or new ones) only the first part (invnumber) is run, and the <bar> and anything that follows is ignored.

  • nmap shows the same output on working and non-working files
  • I thought it might be somehow cached on a name, but new files with names matching working ones do not work either.
  • I tried reversing the order of commands, but only the first is run on non-working files.
  • Removed all plugins, but this behavior persists.
  • Cleaned the vimrc except this line - persists.

What is the problem, or if it's not something simple, how do I debug this?

VIM version is 7.4, (I do not control this) and the plugins I use are matchit, surround, Tabular, and flake8.

1 Answer 1


Your mapping is written badly: you don't need both <CR> and <bar> at the same time. Use either :cmd1<bar>cmd2<CR> or :cmd1<CR>:cmd2<CR>. Moreover, with set you can/should merge both settings into one command: :set invnumber invpaste<CR>.

Another thing you should take into account is that number is local to window, but paste is global. Therefore, they could not always match each other.

  • 2
    Also nnoremap should be used here
    – D. Ben Knoble
    Oct 31, 2019 at 12:33

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.