Rooter is a Vim plugin which changes the working directory to the project root when you open a file.
More accurately, it'll do this when you open a typical webapp file. These files are identified by their extension.
The project root is identified by the presence of known directory, such as a VCS directory, or file, such as a Rakefile. Currently git, darcs, mercurial, bazaar, and subversion are supported.
By default you don't need to do anything: vim-rooter will change the working directory automatically.
You can always invoke vim-rooter manually with
You can change the manual-invocation mapping by adding this to your
map <silent> <unique> <Leader>foo <Plug>RooterChangeToRootDirectory
<Leader>foo is the mapping you want.
You can change the file extensions which trigger vim-rooter with autocommands
~/.vim/after/plugin/vim-rooter.vim. You'll need to create this file, and
possibly the directories, yourself.
To add a file extension, e.g. foo:
autocmd rooter BufEnter *.foo :Rooter
To remove a file extension, e.g. js:
autocmd! rooter BufEnter *.js
To stop vim-rooter changing directory automatically, add this to your
let g:rooter_manual_only = 1
You can set your own directory and file patterns like this:
let g:rooter_patterns = ['Rakefile', '.git/']
Vim-rooter checks the patterns in the order given. So to work correctly with git submodules you should have
Setting your own patterns overwrites the defaults. Directories should have a trailing slash.
You can have vim-rooter locally change directory (
:lcd) instead of
changing directory (
:cd) by adding this to your
let g:rooter_use_lcd = 1
When vim-rooter encounters a non-project file, it won't change directory by default. If you would instead like vim-rooter to change to the file's directory, do this:
let g:rooter_change_directory_for_non_project_files = 1
~/.vim/plugin/rooter.vim or, if you're using Pathogen, into