vim 树形目录插件NERDTree安装及简单用法

1、安装NERDTree插件

先下载,官网:http://www.vim.org/scripts/script.php?script_id=1658

解压缩之后,把 plugin/NERD_tree.vim 和doc/NERD_tree.txt分别拷贝到~/.vim/plugin 和 ~/.vim/doc 目录。


2、使用

1、在linux命令行界面,输入vim

2、输入  :NERDTree ,回车

3、进入当前目录的树形界面,通过小键盘上下键,能移动选中的目录或文件

4、目录前面有+号,摁Enter会展开目录,文件前面是-号,摁Enter会在右侧窗口展现该文件的内容,并光标的焦点focus右侧。

5、ctr+w+h  光标focus左侧树形目录,ctrl+w+l 光标focus右侧文件显示窗口。多次摁 ctrl+w,光标自动在左右侧窗口切换

6、光标focus左侧树形窗口,摁? 弹出NERDTree的帮助,再次摁?关闭帮助显示

7、输入:q回车,关闭光标所在窗口




Q. How can I open a NERDTree automatically when vim starts up?

A. Stick this in your vimrc: autocmd vimenter * NERDTree

Q. How can I open a NERDTree automatically when vim starts up if no files were specified?

A. Stick this in your vimrc

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

Q. How can I map a specific key or shortcut to open NERDTree?

A. Stick this in your vimrc to open NERDTree with Ctrl+n (you can set whatever key you want): map <C-n> :NERDTreeToggle<CR>

Q. How can I close vim if the only window left open is a NERDTree?

A. Stick this in your vimrc:

autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif





你可能感兴趣的:(Web)