转自:http://www.kankanews.com/ICkengine/archives/33966.shtml
摘要:
VIM化繁为简,有人喷:使用vim就是装逼; 默默地回一句话:装逼的是右手。
如果不熟悉vim的,请在使用vim插件之前,请先阅读 Vim学习指南, 建议通过前3个层次。以及有一个有趣的vim练习游戏http://vim-adventures.com/。
插件管理利器
vim的插件原始安装容易混乱,而且管理起来,不方便。那么就渴望一个插件管理工具:pathogen
简单安装:
mkdir -p ~/.vim/autoload ~/.vim/bundle; \ curl -Sso ~/.vim/autoload/pathogen.vim \ https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
详细请查看:https://github.com/tpope/vim-pathogen
配置:
在vimrc文件的filetype plugin之前·「没有的就在最前面」添加:
call pathogen#infect() filetype plugin indent on
,记住,一定是vimrc,而不是gvimrc。可以参考我的vimrc配置
高效插件集
请将这插件安装在$HOME/.vim/bundle目录下:
NerdTree
The NERD tree allows you to explore your filesystem and to open files and directories. It presents the filesystem to you in the form of a tree which you manipulate with the keyboard and/or mouse. It also allows you to perform simple filesystem operations.
你可以使用Git这样安装:
cd $HOME/.vim/bundle git clone https://github.com/scrooloose/nerdtree.git
snipMate
这个可以有。想快速写或者减少重复写代码,那么code snippets就是必须的,而对于vim来说,snipMate,你值得拥有。。请到vim官网下载http://www.vim.org/scripts/script.php?script_id=2540。
tagbar
如果你使用过eclipse,那么它右边有个叫做Outline函数列表,对,tagbar就是这个效果。
你可以使用Git这样安装:
cd $HOME/.vim/bundle git clone https://github.com/majutsushi/tagbar.git
vim-multiple-cursors
这个插件具有Sublime Text的多光标编辑功能哟。
你可以使用Git这样安装:
cd $HOME/.vim/bundle git clone https://github.com/terryma/vim-multiple-cursors.git
如果使用python的,有了它,爽歪歪。它拥有强大的提示能力。
注意,刚开始我安装这个插件,总是报错,主要是vim没有–enable-pythoninterp 和没有安装jedi·「pip install jedi」,而且后来
在jedi-vim开发者David Halter提示下,在.bashrc中设置·「export PYTHONSTARTUP=”$(python -m jedi repl)”
」就可以让python具有ipython的功能。很强大!
你可以使用Git这样安装:
cd $HOME/.vim/bundle git clone https://github.com/davidhalter/jedi-vim.git
其实还可以加一个supertab插件,但是我习惯使用tab来代替空格,实际上一个tab是4个空格。所以并没有列举出来。
你可以使用git这样安装:
cd $HOME/.vim/bundle git clone https://github.com/ervandew/supertab.git
vim配置
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just " /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime " you can find below. If you wish to change any of those settings, you should " do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten " everytime an upgrade of the vim packages is performed. It is recommended to " make changes after sourcing debian.vim since it alters the value of the " 'compatible' option. " This line should not be removed as it ensures that various options are " properly set to work with the Vim-related packages available in Debian. runtime! debian.vim " Uncomment the next line to make Vim more Vi-compatible " NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous " options, so any other options should be set AFTER setting 'compatible'. "set compatible set nocompatible # Just only use vim, not vi " Vim5 and later versions support syntax highlighting. Uncommenting the next " line enables syntax highlighting by default. if has("syntax") syntax on endif " If using a dark background within the editing area and syntax highlighting " turn on this option as well "set background=dark " Uncomment the following to have Vim jump to the last position when " reopening a file "if has("autocmd") " au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif "endif " Uncomment the following to have Vim load indentation rules and plugins " according to the detected filetype. "if has("autocmd") " filetype plugin indent on "endif call pathogen#infect() filetype plugin indent on " The following are commented out as they cause vim to behave a lot " differently from regular Vi. They are highly recommended though. set showcmd " Show (partial) command in status line. "set showmatch " Show matching brackets. "set ignorecase " Do case insensitive matching set smartcase " Do smart case matching "set incsearch " Incremental search "set autowrite " Automatically save before commands like :next and :make "set hidden " Hide buffers when they are abandoned set mouse=a " Enable mouse usage (all modes) set nu set tabstop=4 set softtabstop=4 set shiftwidth=4 set expandtab " use whitespace instead of tab set autoindent set smartindent set cindent shiftwidth=4 set autoindent shiftwidth=4 set foldmethod=indent set colorcolumn=80 " === tagbar setting ======= nmap <F4> :TagbarToggle<CR> " shortcut let g:tagbar_width = 20 " tagbar's width, default 20 autocmd VimEnter * nested :call tagbar#autoopen(1) "automate to open tagbar let g:tagbar_left = 1 " on the left side "let g:tagbar_right = 1 " on the right side let NERDTreeIgnore=['\.pyc', '\.pyo', '\.swp', '\~'] " ignore *.py[co], *.swp and *~ " =======end================== " switch window nnoremap <c-h> <c-w>h nnoremap <c-j> <c-w>j nnoremap <c-k> <c-w>k nnoremap <c-l> <c-w>l " Source a global configuration file if available if filereadable("/etc/vim/vimrc.local") source /etc/vim/vimrc.local endif
一个实例
这是我在写python nose插件nose-colorxunit时截图: