Ubuntu上Vim安装NERDTree插件的详细操作步骤
nerdtree是vim的文件系统浏览器,使用此插件,用户可以直观地浏览复杂的目录层次结构,快速打开文件以进行读取或编辑,以及执行基本的文件系统操作。nerdtree源码在 。
这里通过vundle安装nerdtree,vundle是vim软件包的缩写,是vim插件管理器。vundle源码在https://github.com/vundlevim/vundle.vim 。
安装vundle:
(1). 执行如下命令:
mkdir -p ~/.vim/bundle git clone https://github.com/vundlevim/vundle.vim.git ~/.vim/bundle/vundle.vim
(2). 打开~/.vimrc,在此文件中添加内容如下:
set nocompatible " be improved, required filetype off " required " set the runtime path to include vundle and initialize set rtp+=~/.vim/bundle/vundle.vim call vundle#begin() " let vundle manage vundle, required plugin 'vundlevim/vundle.vim' " keep plugin commands between vundle#begin/end. " 安装其它插件 " all of your plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required
安装nerdtree:
(1). 执行如下命令:
git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree
(2). 打开~/.vimrc,在语句call vundle#end()语句前添加内容如下:
plugin 'preservim/nerdtree'
nerdtree常用快捷键:未说明默认是在命令行模式,命令前有”:”是在底行模式下
1. 通过vim打开一个文件后,在底行模式下输入”nerdtree”后回车进入nerdtree;
2. ctrl+w+h:光标focus左侧树形结构;
3. ctrl+w+l:光标focus右侧文件显示窗口;
4. ctrl+w+w:光标自动在左右侧窗口切换;
5. ctrl+w+r:移动当前窗口的布局位置;
6. o/go:在已有窗口中打开文件,跳到/不跳到该窗口;
7. o:如果光标定位在目录上,点击”o”则会展开或合拢该目录;
8. t/t:在新的tab中打开文件,跳到/不跳到新tab;
9. :tabc/:tabo:关闭当前的/关闭所有其它的tab;
10. :tabp/:tabn:跳到前一个/跳到后一个tab;
12. i/gi:split一个新窗口并打开选中文件,跳到/不跳到该窗口;
13. s/gs:vsplit一个新窗口并打开选中文件,跳到/不跳到该窗口;
14. x:合拢当前文件或目录的父目录;
15. p/p:跳到根结点/父结点;
16. c:将选中目录或选中文件的父目录设为根结点;
17. u/u:将当前根结点的父目录设为根结点,并合拢原根结点/展开原根结点;
18. r/r:递归刷新选中目录/根结点;
19. i:切换是否显示隐藏文件;
20. q:关闭nerdtree窗口。
打开nerdtree后界面如下:
完整的~/.vimrc文件内容如下:
" 安装vundle: 参考:https://github.com/vundlevim/vundle.vim " $ mkdir -p ~/.vim/bundle " $ git clone https://github.com/vundlevim/vundle.vim.git ~/.vim/bundle/vundle.vim set nocompatible " be improved, required filetype off " required " set the runtime path to include vundle and initialize set rtp+=~/.vim/bundle/vundle.vim call vundle#begin() " let vundle manage vundle, required plugin 'vundlevim/vundle.vim' " keep plugin commands between vundle#begin/end. " 安装nerdtree " $ git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree plugin 'preservim/nerdtree' " all of your plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required " to ignore plugin indent changes, instead use: "filetype plugin on " 语法高亮显示 syntax on " 缩进设置 set tabstop=8 set softtabstop=8 set shiftwidth=8 " c代码缩进 set cindent " 搜索结果高亮显示 set hlsearch " 解决中文字符显示乱码 set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 set termencoding=utf-8 set encoding=utf-8
总结
到此这篇关于ubuntu上vim安装nerdtree插件操作步骤的文章就介绍到这了,更多相关vim安装nerdtree插件内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!