How can I override ~/.vim and ~/.vimrc paths (but no others) in vim?

前端 未结 4 1856
挽巷
挽巷 2021-01-31 04:56

Let\'s say I have a tarball of all my vim config - everything normally inside ~/.vim (plugins, autoload, colours, all that stuff), and a vimrc file. I extract this to a director

4条回答
  •  逝去的感伤
    2021-01-31 05:20

    I have a portable .vim folder exactly as you described, this is how I have set it up:

    • Put your portable .vimrc file inside your .vim folder.

    • Add the following lines to the start of your portable .vim/.vimrc:

    " set default 'runtimepath' (without ~/.vim folders)
    let &runtimepath = printf('%s/vimfiles,%s,%s/vimfiles/after', $VIM, $VIMRUNTIME, $VIM)
    
    " what is the name of the directory containing this file?
    let s:portable = expand(':p:h')
    
    " add the directory to 'runtimepath'
    let &runtimepath = printf('%s,%s,%s/after', s:portable, &runtimepath, s:portable)
    
    • Start vim by using: vim -u /path/to/portable/vim/.vimrc.

提交回复
热议问题