sponsor Vim development Vim logo go to HTTPS page Vim Book Ad

projectroot : Automatic guessing of projectroots

 script karma  Rating 1/1, Downloaded by 213    Comments, bugs, improvements  Vim wiki

created by
Daan Bakker
script type
Github project: https://github.com/dbakker/vim-projectroot

There already are a ton of plugins (such as CtrlP) that try to guess what the main project folder is of a file that you're working on, but this plugin allows to easily re-use that functionality in your own custom mappings or scripts.

  * Works out-of-the-box on most projects by detecting folders such as .git.
  * Very customizeable.
  * Easy to use in mappings and your own scripts, just call ProjectRootGuess() to get the project root of the current file or ProjectRootGuess(file) for another file.
  * Can be combined with existing plugins
  * Tries to be as lightweight as possible. Only searches for a project root when a method such as ProjectRootGuess is used.

Methods provided:
  * ProjectRootGuess([file]): Returns the project root for the given file (or for the current file if none is given).
  * ProjectRootExe(cmd): Temporarily changes the current directory to that of the project root, then executes the command.
  * ProjectRootCD([file]): Changes the current directory to project root of the given file.
  * ProjectRootBuffers([file]): Returns all buffers belonging to the same project of the given file.

For example, to automatically change the current directory to the projectroot of the current file you could add this to your .vimrc:

au BufEnter * if &ft != 'help' | call ProjectRootCD() | endif
install details
My recommended way of installing this plugin would be by using Vundle or Pathogen, and pointing them at https://github.com/dbakker/vim-projectroot .

To manually install the plugin just download projectroot.zip and put projectroot.vim in your plugin/ folder. However, if you are contemplating to use this you're probably advanced enough to know this yourself. :)

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
projectroot.zip 1.0 2013-01-06 7.0 Daan Bakker Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo