Reputation: 1839
Before today I was using /etc/vim/vimrc
to configure my vim setup. Today I thought of creating .vimrc
file. So, I used
touch .vimrc
cat /etc/vim/vimrc > .vimrc
So, now when I open any file with vim I get the following errors:
Error detected while processing /home/ronnie/.vimrc:
line 68:
E122: Function SplitColors already exists, add ! to replace it
line 77:
E122: Function ChangeColors already exists, add ! to replace it
line 171:
E174: Command already exists: add ! to replace it
line 174:
E174: Command already exists: add ! to replace it
Press ENTER or type command to continue
I have both /etc/vim/vimrc
and .vimrc
file located in my system. So, is this the reason I am getting this error because from now on I would like to use only .vimrc
to configure my vim setup.
Upvotes: 9
Views: 6929
Reputation: 357
This is the solution by example since most of the answers are correct above but they don't directly help you solve the problem. Areas of interest in bold.
" code with redefinition issues
function CloseDuplicateTabs() endfunction
command CloseDupTabs :call CloseDuplicateTabs()
" fixed code with overrides
function! CloseDuplicateTabs() endfunction
command! CloseDupTabs :call CloseDuplicateTabs()
Upvotes: 6
Reputation: 172510
The problem is that both /etc/vim/vimrc
and .vimrc
are sourced. This depends on several factors; see the details at :help .vimrc
.
In general, the system-wide Vim config should reside in the former file, and your personal customizations in the latter. For single-user systems, there isn't much of a difference, but you did the right thing in moving the stuff into your home directory. Just delete the duplicate functions etc. from the former file, or remove it completely if you've moved everything to your .vimrc
.
Upvotes: 4
Reputation: 62528
You're defining functions that have the same name as some already defined. Adding an exclamation mark after function
"overwrites" the previous definition, and in your case will stop the error message from showing.
Upvotes: 14
Reputation: 5949
Why not add ! to your function definitions as suggested? it will make vim stop complaining.
Alternatively you could remove those definition from /etc/vim/vimrc
Upvotes: 4