MacVim Tip: Tabs Per Project Nov 20

I dislike having too many windows open on my desktop. If I can consolidate them then I will. Here’s a tip to do this with MacVim.

Use :lcd path/to/proj instead of :cd path/to/proj in the new tab.

:cd will change the working directory for the whole window, while :lcd does it for the current window.

My vim setup uses ack.vim, NERDTree, and command-t plugins. These depend on the current working directory. If you’ve ever decided to open another project in another tab instead of another window, you know that running these plugins will not search within the new project directory. Well, now when you open a new tab use :lcd to move to that directory first.

For more info on :cd and :lcd you can run :help current-directory to find out more.