sourcing the .vimrc gives E174 error

4

I am using vim on a Mac os X. After editing my .vimrc file and I want to try to reload it without restarting vim. But it gives me the following error.

E174: Command already exists: add ! to replace it

Can anyone tell me why this is happening and how I can reload my .vimrc without restarting?

minibuffer

Posted 2014-10-22T15:53:07.860

Reputation: 143

Answers

4

The error is caused by a missing ! after a :command:

BAD

command Foo echo "foo"

GOOD

command! Foo echo "foo"

See :help e174.


You reload your ~/.vimrc with this command:

:so $MYVIMRC

The answers to both questions can be found in Vim's documentation.

romainl

Posted 2014-10-22T15:53:07.860

Reputation: 19 227

1Did you even READ the answer? Nowhere does it suggest adding ! after the :so command! – Ben – 2014-10-29T12:03:37.147

1

The error happens because the key you are trying to map is already mapped to something else. Adding a ! overwrites your previous binding.

So if the line. that causes the error is:

:map <F6> :so $HOME/.vimrc<CR>

substitute it with:

:map! <F6> :so $HOME/.vimrc<CR>

Einar

Posted 2014-10-22T15:53:07.860

Reputation: 193