Telling Vim to use custom .vimrc is easy, but how to tell it to use alternative path instead of ~/.vim?
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Darkness Approaches Looping
--
Chapters
00:00 Telling Vim To Use Custom .Vimrc Is Easy, But How To Tell It To Use Alternative Path Instead Of ~/.V
01:39 Answer 1 Score 3
01:58 Accepted Answer Score 10
03:01 Thank you
--
Full question
https://superuser.com/questions/561434/t...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#commandline #vim #vimrc
#avk47
ACCEPTED ANSWER
Score 10
Vim looks in ~/.vim because that directory is in the default list in 'runtimepath', abbreviated as 'rtp'. To tell Vim to look elsewhere, you will have to completely specify a different 'rtp' value, or edit the default using a call to substitute() for example. If you just want Vim to look in a different place for your configuration files first, don't care that it also looks in ~/.vim, and don't care that it doesn't look in your alternative after directory, the command is pretty simple:
vim --cmd 'set rtp^=alternate_dir'
See
:help --cmd
:help :set^=
Replacing .vim with your alternative directory takes a little more typing.
vim --cmd 'let &rtp = substitute(&rtp, "\.vim", "alternate", "g")'
I tried replacing ~/.vim with another path, but I couldn't match the ~, so I went ahead and posted what I had.
Edit
The reason I could not match the ~ in the value of 'rtp' is that when the value is obtained as the value of &rtp rather than the output of :set rtp?, the ~ is expanded to the full path name of the user's home directory. There is no ~ in the result.
The following works.
vim --cmd 'let &rtp = substitute(&rtp, $HOME."/\.vim", "alternate", "g")'
ANSWER 2
Score 3
In the .vimrc you choose, you can specify the runtime path:
let &runtimepath=/path/to/specific/vim/folder
If you are using your person .vimrc then you could set this to your personal .vim directory and it should work both as su and your normal account.