27

Is it possible to put the .vimrc into the .vim folder so that I only have to sync the whole folder and not folder and file to other computers?

4 Answers4

30

Starting in Vim 7.4 you can also just place a file vimrc into $HOME/.vim/vimrc or $HOME/vimfiles/vimrc for Windows and Vim will find it automatically.

Note, this is vimrc without a . (dot) or _ (underscore) like the traditional .vimrc/_vimrc file would have.

Ben
  • 2,299
  • 20
  • 19
16

I keep my .vimrc in .vim and symlink it.

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

On Windows I believe you can do the same with mklink.

5

If you were to create an alias for vim to specify the location of the .vimrc like thus:

alias vim='vim -u ~/.vim/vimrc'

then you could do away with having .vimrc separate.

BUT

This will cause issues with other programs interacting with vim. Pressing 'v' in 'less' will not work, since it calls vim via the contents of the EDITOR env-variable. I suppose you could add the '-u ...' bit into the EDITOR variable. might work.

For gvim, you'd use an uppercase 'U' there, to specify the location of the .gvimrc file. Again, issues ensue unless you change EVERY possible starting location of gvim in your window manager's starting links.

All in all, I'd suggest using @remyo's suggestion if you MUST have it all in one subdir.

It's relatively easy to create a post-pull script that would reestablish the link between 'repo/.vimrc' and '~/.vimrc'.

Good luck.

(you could recompile vim yourself, specifying a new default location for the .vimrc file.)

lornix
  • 11,909
2

That's exactly what I do, with this single line in my ~/.vimrc:

runtime vimrc
romainl
  • 23,415