开发者

Vim Editor open always users home directory

I installed Nerd_tree plugin for vim on ubuntu 10.04. It is great plugin. But I met the following problems:

  1. after open nerd_tree to browse the files in /etc/apache2/sites-available/, now I close it, and go on with my work. Later I want open nerd_tree again to edit another file in /etc/apache, but nerd_tree shows me always the user home directory /home/toledot, So I ha开发者_开发技巧ve to up dir->up-dir->up-dir again. Is there a way let nerd_tree to remember the path, which I have used at the last minute?
  2. I opened nerd_tree and select one file to edit. After my update on this file, and want to select another file to make some change. But I can not go back to the nerd_tree. I tried to make double click and tab and so on. It doesn't work. What is the hotkey to switch nerd_tree and the opened files in vim?

I am absolute new with vim and plugins, so please help me and explain the solution in details. I am very thankful for any suggestion or infos.


A couple of points that may be helpful.

  1. If you set autochdir the current working directory will be automatically be set to that of the current file. You can do this either interactively or in your .vimrc file.
  2. The official way to open the NERDTree window seems to be with the command :NERDTree. You can map this to any convenient key sequence.
  3. You should be able to view the helpfile with the command :help NERDTree. If you have trouble getting the help, change to the directory containing file NERD_tree.txt (in vim) and execute :helptags .
  4. You can also add bookmarks for file/directories that you often use. See
    :help NERDTreeBookmarkCommands.


What you need is a handy map to :NERDTreeToggle. Put this in your .vimrc

nmap <silent> <F4> :NERDTreeToggle<CR>

And just hit <F4> to open/close NERDTree, just like that, just as you last toggle-closed it.


You can also open a specific directory using :NERDTree /my/dir

I advise you to set autochdir so that whenever you open a file, working directory (you can find out this with :pwd) will be changed accordingly

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜