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?

4
  • 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
    Commented Jun 12, 2020 at 0: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
    Commented Jun 12, 2020 at 3: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
    Commented Jun 12, 2020 at 4:31
  • A good resource for your future mappings issues: How to debug a mapping
    – statox
    Commented Jun 12, 2020 at 7:30

0

Browse other questions tagged or ask your own question.