24

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?

  • 2
    You might consider keeping all of your dotfiles in a revision controlled repository. All my dotfiles are kept in a directory managed by git. This repo also contains a scripts to check for diffs between the repo and the installed dotfiles, and a script to copy the dotfiles to their proper locations. To set up another machine, I basically copy the repo and run the install script. – Roland Smith Aug 18 '13 at 15:51
  • I got the same system, my dotfile even get compiled from a lot of separate source files, since a single file was becoming too long :-D – Martin Ueding Aug 21 '13 at 19:25
  • @RolandSmith How do you set up a repo with your dot files? One way I can think of is to run git init in your home folder and excluded everything but the dot files that you want to keep track of. – adammendoza Dec 11 '16 at 6:39
  • @adammendoza I do not manage them in-place. I gather everything into a directory tree and use a script called deploy to install them. Read the description on the linked github page to see how it works. – Roland Smith Dec 17 '16 at 15:16
  • There is a tool called VCSH that lets you track them in guy from your home directory but keeps the repo somewhere else. – Martin Ueding Dec 17 '16 at 17:59
29

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.

| improve this answer | |
  • Sounds good. If you like, you can put your code into backticks. – Martin Ueding Aug 8 '13 at 16:09
  • 7.4 is now out of beta, too...so this is probably the best way to do it now. – Ben Aug 16 '13 at 18:51
  • +1 for my new standard way of usign those files. In case I'm on a machine that doesn't use 7.4 but an older version, I can always make a symlink... – polemon Aug 17 '13 at 17:58
  • @Ben: Well, it will take a while until I have 7.4 on my Ubuntu machine without any backports, so it will stay that way for now. – Martin Ueding Aug 18 '13 at 10:42
15

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.

| improve this answer | |
  • I do this, and also have the .vimrc directory on github which makes it very easy when setting up a new account. This is described in the first steps of this vimcast – pmac72 Jun 26 '12 at 21:16
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.)

| improve this answer | |
  • 1
    Okay, that sounds like creating more problems than solving. – Martin Ueding Jun 19 '12 at 7:33
2

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

runtime vimrc
| improve this answer | |
  • 2
    Okay, but I still got to have a .vimrc then. Then I just use the one you gave me in the other question. – Martin Ueding Jun 18 '12 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.