Hamid Bazargani
Hamid Bazargani

Reputation: 868

How to make vimrc changes to take effect

I have a problem using my .vimrc. I am under Linux Red hat and whatever I change in ~/.vimrc does not take effect. To make it reflected, each time I open vim files (let say hello.txt), I need to source so:~/.vimrc to make my new changes reflected. But I don't want to do sourcing every time. I wonder if there would be a way to source it once and have all new configurations valid.

I also should note that I do not have root access and I had to create my own .vimrc for the first time. It did not exist in my $HOME directory.

Thanks in advance.

UPDATE:

>which vim
/usr/bin/vim
>ls -la ~/.vimrc
-rwxrwxrwx. 1 username ...

my system wide Vim initialization:

/usr/share/vim/vimrc

my personal Vim initializations

~/.vimrc

UPDATE 2:

:scriptnames:

1: /etc/vimrc
 2: /usr/share/vim/vim72/syntax/syntax.vim
 3: /usr/share/vim/vim72/syntax/synload.vim
 4: /usr/share/vim/vim72/syntax/syncolor.vim
 5: /usr/share/vim/vim72/filetype.vim
 6: /usr/share/vim/vim72/ftplugin.vim
 7: /usr/share/vim/vim72/indent.vim
 8: /usr/share/vim/vim72/syntax/nosyntax.vim
 9: /usr/share/vim/vim72/plugin/filetype.vim
 10: /usr/share/vim/vim72/plugin/getscriptPlugin.vim
 11: /usr/share/vim/vim72/plugin/gzip.vim
 12: /usr/share/vim/vim72/plugin/matchparen.vim
 13: /usr/share/vim/vim72/plugin/netrwPlugin.vim
 14: /usr/share/vim/vim72/plugin/rrhelper.vim
 15: /usr/share/vim/vim72/plugin/spellfile.vim
 16: /usr/share/vim/vim72/plugin/tarPlugin.vim
 17: /usr/share/vim/vim72/plugin/tohtml.vim
 18: /usr/share/vim/vim72/plugin/vimballPlugin.vim
 19: /usr/share/vim/vim72/plugin/zipPlugin.vim

Upvotes: 1

Views: 12241

Answers (5)

Krafty Coder
Krafty Coder

Reputation: 71

This works fine for me; Inside your vim write the following command

:source ~/.vimrc

This starts feeding commands from the .vimrc file

The .vimrc file is a file that collects all that .vim(...) files and combines all of them.

When you search .vim... you will get many other files starting with .vim These files are the ones that feed the .vimrc file

Upvotes: 2

Tatiana Tylosky
Tatiana Tylosky

Reputation: 11

Here are two mappings I have in my vimrc to quickly open and refresh my vimrc file. After you add these make sure to open a new window so they can go into effect though :)

"refreshes for any vimrc updates
map <C-r> :source ~/.vimrc<CR>

"opens vimrc
map <C-o> :e ~/.vimrc<CR>

Upvotes: 1

Hamid Bazargani
Hamid Bazargani

Reputation: 868

Well, I found the solution.

The reason that I was not able to make any changes get reflected from ~/.vimrc was because of VIMINIT. I had VIMINIT set in my shell configuration (.cshrc). And according to the vim documentation, VIMINIT has load precedence over .vimrc.

Upvotes: 5

Ingo Karkat
Ingo Karkat

Reputation: 172768

So, your general configuration in ~/.vimrc works, but you don't see new changes applied immediately?

That's because Vim only reads the ~/.vimrc once during startup. So in general, you have to :quit Vim and restart it. You can define autocmds that automatically reload your ~/.vimrc on writes, see Change vimrc with auto reload. Some options are buffer-local and are only derived from the global defaults. For those, even such reload won't affect them.

Upvotes: 2

milli
milli

Reputation: 484

$ vim

then after it's started, type

:help initialization

That will explain what files are sourced on startup and in what order, then you can figure it out from there.

And it's normal for .vimrc and a .vim directory to not exist for a new user account.

Upvotes: 0

Related Questions