一直听说vim,emacs两大神器,于是选了一直在用的vim来体验一下
先放个最后的效果图
最初目的是打算搞出来写django的,于是很多插件配置用的官方文档推荐的
https://code.djangoproject.com/wiki/UsingVimWithDjango
1、首先需要插件管理 Vundle
这个方式只修改当前用户的vim
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
编辑vimrc
vim ~/.vimrc
set nocompatible
filetype on
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
call vundle#end()
filetype plugin indent on
安装插件:进入vim,输入 :PluginInstall
或者直接命令行执行 vim +PluginInstall +qall
卸载插件:在vimrc中删除相应行后
进入vim ,输入 :PluginClean
其它用法github上看吧。。。
2、自动补全插件 Plugin ‘Valloric/YouCompleteMe’
https://github.com/Valloric/YouCompleteMe
先用vundle安装,PluginInstall会报错需要单独安装,执行下面步骤即可
PluginInstall过程很慢而且没有进度条显示,可以进入~/.vim/bundle/YouCompleteMe/目录查看大小是否在增长,我的有307M
sudo apt install build-essential cmake python3-dev
cd ~/.vim/bundle/YouCompleteMe
python3 install.py
clang之类的暂时用不到,参数就全都没加
3、目录树显示插件 Plugin ‘scrooloose/nerdtree’
vimrc中配置如下
Plugin 'scrooloose/nerdtree'
let g:NERDTreeChDirMode=2 #将当前目录设置为nerdtree根目录
map <C-n> :NERDTreeToggle<CR> #设置快捷键,ctrl+n打开nerdtree
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif #这两行是打开目录是自动打开nerdtree,比如vim . 时
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif #只剩下nerdtree窗口时自动关闭vim
ctrl+w+w 切换窗口,vim和nerdtree之前切换
shift+c 将当前目录设为根节点
shift+r 刷新当前根目录
o