Error opening files after creating ~ / .vimrc

Until today, I have used /etc/vim/vimrc to configure my vim installation. Today I was thinking of creating a .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 a /etc/vim/vimrc and .vimrc file located on my system. So the reason is that I am getting this error because now I would like to use only .vimrc to configure my vim installation.

+7
source share
4 answers

You define 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.

+11
source

This solution is an example, since most of the answers are correct above, but they do not directly help you solve the problem. Areas of interest in bold.

"with redefinition problems

CloseDuplicateTabs () function endfunction

CloseDupTabs command : call CloseDuplicateTabs ()

"fixed code with overrides

function! CloseDuplicateTabs () endfunction

team! CloseDupTabs: call CloseDuplicateTabs ()

+4
source

Why not add! to your function definitions as suggested? this will make vim stop complaining.

Alternatively, you can remove this definition from / etc / vim / vimrc

+3
source

The problem is that both /etc/vim/vimrc and .vimrc . It depends on several factors; see :help .vimrc details.

In general, the system-wide configuration of Vim should be in the first file and your personal settings in the last. For single-user systems, the difference is not very important, but you correctly placed the material in your home directory. Just remove duplicate functions, etc. From the previous file or completely delete it if you moved everything to your .vimrc .

+3
source

All Articles