0

I am trying to add the following mapping into my vimrc:

nnoremap <leader>sv :source $MYVIMRC | filetype detect<cr>

This works in command mode, however, in the mapping I get:

E475: Invalid argument: detect

Why does it throw that error? What would be the proper way to get around it?

David542
  • 2,445
  • 14
  • 50
  • You need to escape the bar: \| or use <bar> instead..per :h :bar. But this shouldn't work from the command line either. Unescaped bar is always illegal "as an argument". – B Layer Jun 12 '20 at 00:31
  • @BLayer to source? It should work fine if typed literally, unless source doesnt allow bar separator (a very few commands dont) – D. Ben Knoble Jun 12 '20 at 03:06
  • 1
    @D.BenKnoble Quoted part is from help...an arg to nnoremap is what I was thinking. I.e. unescaped bar doesn't ever work on the rhs of mappings, I believe. – B Layer Jun 12 '20 at 04:31
  • A good resource for your future mappings issues: How to debug a mapping – statox Jun 12 '20 at 07:30

0 Answers0