Possible Duplicate:
set .vim home directory to something specific
There is already a question about setting a working directory: How to set working/current directory in Vim? However my problem is a little different, I have several thousands files (several different projects) in a folder. Whenever I start Vim (MacVim), the cwd is by default set to home dir. Thus when I'm using plugins like ack.vim they by default are searching in my home dir which is useless. I just want to set it to my /home/user/Code folder (which has all my snippets, projects,etc..)
Is there any settings which sets the cwd to a certain directory? Or any workarounds (like executing :cd /home/user/Code
for every startup in Vim?
Best Answer
You could just hard-code the current working directory via
in your
~/.vimrc
. But that leads to a strange setup whenever you edit files elsewhere. (And even if you're mainly editing inside yourCode
directory, there is the occasional edit of~/.bashrc
, or a config setting in/etc/...
, and so on.What I do is put the
:cd
into a local vimrc inside theCode
directory. (I use the localrc.vim plugin; there are others.) Then, the directory is changed only when I actually edit any file withing that directory tree.