Luc M
Luc M

Reputation: 17304

What is the issue with vim -u /path_to/vimrc?

I share an user with other people.
Everyone has created a directory into home directory and everyone is working in his "own" directory.
I want to use my own setting when I use vim and I don't want to bother others with my preferences.

I created my .vimrc file into $HOME/my_directory

I've defined an alias my_vim="vim -u /full_path_to_home/my_directory/.vimrc"

When I edit a file with my_vim, I don't have the right colors.

I have the same problem when I use the command
:source /full_path_to_home/my_directory/.vimrc

If I copy my .vimrc file into $HOME directory, everything is fine.

Where is the problem ?

Upvotes: 5

Views: 773

Answers (2)

Karl Bielefeldt
Karl Bielefeldt

Reputation: 49008

If this sort of thing comes up a lot, I would recommend changing your $HOME to point to the current $HOME/my_directory whenever you log in.

Upvotes: 1

moinudin
moinudin

Reputation: 138317

From :help vimrc

If Vim was started with "-u filename", the file "filename" is used. All following initializations until 4. are skipped.

So by specifying a vimrc file, its ignoring the system-wide vimrc (/erc/vimrc/) where syntax highlighting and other things are configured. You can work around this problem by adding the following code to the top of your vimrc:

if filereadable("/etc/vimrc")
  source /etc/vimrc
endif

Upvotes: 3

Related Questions