Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Does anyone know a good/neat way to create directory shortcuts in Vim?

Akin to the "~[shortcut]" in Zsh which you can use to quickly specify a directory.

I could create aliases in my home directory and use "~/[alias]" but it would be nice if I could have something only available in Vim.

share|improve this question

5 Answers 5

up vote 1 down vote accepted

You can use cmdalias for Vim. Then you can make custom aliases such as cdsrc to change to a directory like /home/user/project/source.

share|improve this answer

There is a FavEx plugin: http://www.vim.org/scripts/script.php?script_id=539

share|improve this answer

NerdTree provides bookmarks handling. See ":h NerdTreeBookmarks".

While not directly accessible via ":cd", there is at least ":NERDTreeFromBookmark", where you can then "cd" to this (or another dir).

Also "B" in the NERDTree window will toggle display of bookmarks, and allows to easily access them.

share|improve this answer
    
NerdTree looks awesome. Thanks! –  Daisuke Shimamoto Dec 13 '11 at 7:15

Something like

let $vimfiles = "c:\\ldigas-home\\gvim72\\vim\\vimfiles"

so when I go

 cd $vimfiles  

it puts me in

c:\ldigas-home\gvim72\\vim\vimfiles

Or did you have something else in mind ?

share|improve this answer

One way I solved this was by having something like this:

nnoremap <silent> <leader>hd :e ~/daisuke

in my .vimrc. This will populate the command with ":e ~/daisuke" with the cursor at the end. This actually suites me well as majority of the time, I want to edit a file under that directory not necessarily just cd to it (sorry should have been more clear about this!)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.