Change default location of vimrc

前端 未结 8 1713
一向
一向 2020-12-13 05:52

In Vim, is it possible to change the default location of the user vimrc file, i.e., from $HOME/.vimrc to some other location ?

8条回答
  •  情话喂你
    2020-12-13 06:35

    On Windows, I have the _vimrc that's in my home directory contain one line, source c:\path\to\my.vimrc.

    I have not yet worked out a good way to move the entirety of my vimfiles folder, but that's less critical as it's all stuff I've installed from elsewhere. I.e., it'd be easy to restore if I lost it. (I know that I can change runtimepath but my problem is more coming up with a "good" way to do so.)

    Update

    After six years I extended slightly from what I mention in the comments below; as I put stuff into 'after' and wanted to just keep rtp clean I got something that has been solid for a while now. Today in my %USERPROFILE%\_vimrc I do hardcode the actual paths to things and it changes on every machine I use (and I basically do the same thing on *nix) but this gets copied around mostly-manually when setting up a new PC. I also have a version which I can use to launch Vim on another connected machine on the network, e.g. a co-worker's machine, so I get my config and all that, but the gist is:

    set runtimepath^=E:/dotfiles/vim
    set runtimepath+=E:/dotfiles/vim/after
    set runtimepath-=~/vimfiles
    set runtimepath-=~/vimfiles/after
    runtime vimrc
    

    and then %USERPROFILE%\_gvimrc just has one line:

    runtime gvimrc
    

    (Both vimrc and gvimrc are in the /dotfiles/vim folder and also on Bitbucket.)

提交回复
热议问题