平日使用vim经常编辑文件,想想使用时的痛点,决定研究一下插件的使用。先列一些几个痛点问题:
- python空格对齐问题;
- python自动补齐;
- 函数定义的快速跳转;
Vim的扩展通常也被成为bundle或插件。
插件安装-Vundle
众多文章中都推荐Vundle,那我就选用它好了!
1.将Vundle下载到本地,后面下载的插件也将会下载到~/.vim/bundle路径下。
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
2.插件配置,将如下的内容粘贴到~/.vimrc的顶部(前提是,你本身.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()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
" Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
" Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
" Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
" 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
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
3.安装插件,打开vim,然后输入:
:PluginInstall
4.卸载插件
# 注释下面这段话
# Plugin 'Valloric/YouCompleteMe'
然后
:PluginUpdate
:PlugginClean
参考:
NERDTree
Plugin 'scrooloose/nerdtree'
"F2开启和关闭树"
map <F2> :NERDTreeToggle<CR>
let NERDTreeChDirMode=1
"显示书签"
let NERDTreeShowBookmarks=1
"设置忽略文件类型"
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
"窗口大小"
let NERDTreeWinSize=25
YouCompleteMe
Plugin 'Valloric/YouCompleteMe'
sudo apt-get install build-essential cmake
sudo apt-get install python-dev python3-dev
cd ~/.vim/bundle/YouCompleteMe
./install.py --all
cp ~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/.vim/
"YouCompleteMe配置相关
let g:ycm_server_python_interpreter='/usr/bin/python'
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'
主题
安装两个主题,GUI模式可以尝试solarized方案, 终端模式可以尝试Zenburn方案:
Plugin 'jnurmine/Zenburn'
Plugin 'altercation/vim-colors-solarized'
if has('gui_running')
set background=dark
colorscheme solarized
else
colorscheme Zenburn
endif
安装完成之后,需要:
mkidr ~/.vim/colors
cp ~/.vim/bundle/Zenburn/colors/zenburn.vim ~/.vim/colors/
cp ~/.vim/bundle/vim-colors-solarized/colors/solarized.vim ~/.vim/colors/
解决办法参考: E185: Cannot find color scheme 'solarized'
有关主题的命令:
:colorscheme "查看当前主题
:colorscheme space tab "列出所有主题
:colorscheme your-theme "切换主题