4

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 ?

Luc M
  • 16,630
  • 26
  • 74
  • 89

2 Answers2

2

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
moinudin
  • 134,091
  • 45
  • 190
  • 216
  • @ajwood With the information provided, I don't see how it can't be a possible solution. – moinudin Dec 23 '10 at 21:15
  • Sorry, you must have edited the answer as I was typing the comment. I thought you'd only quoted the docs. +1 – ajwood Dec 23 '10 at 22:07
1

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.

Karl Bielefeldt
  • 47,314
  • 10
  • 60
  • 94
  • There might be a good reason he's sharing home directories, and editing `$HOME` might mess around with that reason. – moinudin Dec 23 '10 at 21:17
  • 1
    I didn't mean in the .bashrc or whatever, I meant manually typing `export HOME=$HOME/my_directory` when he opens a terminal for himself. – Karl Bielefeldt Dec 23 '10 at 21:19