How to change the default location of .vimrc to inside ~/.vim/?

You don't. Symlink it instead.

mv ~/.vimrc ~/.vim
ln -s  ~/.vim/.vimrc ~/.vim

You cam do the symlink thing to sync your vimrc through Dropbox as well.


digitxp's answer is probably the better one, but you can tell Vim to look for your vimrc anywhere you like with the -u command-line option, and gvimrc with -U, e.g.:

vim -u ~/.vim/vimrc -U ~/.vim/gvimrc

Vim 7.4 also sources ~/.vim/vimrc by default. help vimrc says:

Unix $HOME/.vimrc or $HOME/.vim/vimrc

But my current favorite solution for backing up files anywhere is https://github.com/technicalpickles/homesick which concentrates all config files in a single place and handles symlink management for you.

See also: https://stackoverflow.com/questions/3377298/how-can-i-override-vim-and-vimrc-paths-but-no-others-in-vim

Tags:

Vim