Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference/source a custom .vimrc file

Tags:

vim

Is there a way to reference (or "source") another user's .vimrc file?

When I kuu (a variant of su that uses kerberos security tokens) to an admin user ID, I would like to use my personal .vimrc file.

I don't want to overwrite the admin's existing .vimrc file because the admin ID is shared by multiple users.

like image 506
Mansoor Siddiqui Avatar asked Jan 06 '11 18:01

Mansoor Siddiqui


People also ask

How do I access .vimrc files?

The global or system-wide vim configuration file is generally located under the /etc/vim/vimrc . This configuration file is applied to all users and when Vim is started this configuration file is read and Vim is configured according to this file contents.

How do I open a .vimrc file in Terminal?

In the terminal, type vi . vimrc . This will create an empty vimrc system file which you want to use. In the file, type set number , and then hit Esc on the keyboard and type in :wq .

How do I open a .vimrc file in Windows?

Opening vimrc Using file name completion, you could type :e $M then press Tab until you see the desired variable. If you only want to see the path, type :echo $M then press Tab to see the variable, and press Enter. In gvim, the Edit menu includes "Startup Settings" which will use $MYVIMRC to edit your vimrc file.


3 Answers

Try -u parameter and specify a path to an alternative configuration file.

For example: vim -u /home/jesse/myvimrc

See http://linuxcommand.org/lc3_man_pages/vim1.html

like image 143
Jesse Vogt Avatar answered Sep 23 '22 07:09

Jesse Vogt


You can use the MYVIMRC environment variable. This way, you won't have to pass -u each time you fire up vim. (You can of course do an alias instead, but that won't help with e.g., vipw)

Keep in mind that .vimrc can execute arbitrary commands, if you use /home/user/.vimrc you may be creating a security issue (e.g., someone manages to compromise your user account, changes your .vimrc, and then gets root the next time you edit a file as root). You can, of course, keep a known-safe copy in ~root/ somewhere.

You could assumably even set something up in ~root/.bashrc to automatically set MYVIMRC to something different for each different administrator.

like image 34
derobert Avatar answered Sep 26 '22 07:09

derobert


Use an alternate .vimrc file without plugins as mentioned, and add an alias in .bash_profile or something.

alias svim='vim -u ~/.vimrc_simple'

Really I prefer the following:

alias vvim='vim -u ~/.vimrc_vundle'

In order to keep vim as a lightweight command, as plugin loading seems to slow down program instantiation.

like image 45
mpeaton Avatar answered Sep 22 '22 07:09

mpeaton