gVim安装安装只需一个命令:
sudo apt-get install vim-gtk
下面重点讲插件的安装和配置。
要安装的插件包括:
nerdtree:文件和目录浏览。
ctrlp.vim: 代码和文件模糊查找。
syntastic:支持各种语言的语法检查。
fugitive:git集成。
PIV: PHP集成环境,自动产生PHP文档,Shift+K查看PHP函数文档。
tagbar:函数列表。
ultisnips:提供代码模板功能,但不包含各语言的代码模板。
vim-snippets:提供各种语言的ultisnips的代码模板。
youcompleteme:无处不在的自动补齐
supertab:让ultisnips与youcompleteme协同工作
vim-airline:强大的状态栏。
echofunc:了解函数参数。
vim-twig:Twig模板支持。
vim-css-color:所见及所得的CSS颜色。
vdebug:PHP、Python等可视化调试。
vim-gitgutter:显示文件每一行的修改状态。
通过apt-get安装Ubuntu提供的插件:
Ubuntu已经提供了youcompleteme等插件,可以直接安装:
$ sudo apt-get install vim-youcompleteme
$ vim-addons install youcompleteme
安装matchit插件:
$ vim-addons install matchit
Ubuntu15.04已经提供了fugitive和syntastic等插件,可以直接安装:
$ sudo apt-get install vim-fugitive vim-syntastic vim-ctrlp vim-ultisnips vim-snippets
$ vim-addons install ctrlp
(对于Ubuntu15.04以前的版本,这些插件只能通过Vundle安装)
tagbar要用到ctags,需要先安装:
$ sudo apt-get install exuberant-ctags
其他插件需要通过Vundle安装,先安装Vundle:
mkdir ~/.vim/bundle
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
编辑~/.vimrc配置Vundle:
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 'gmarik/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'spf13/PIV' " PHP Integration environment
Plugin 'majutsushi/tagbar'
Plugin 'bling/vim-airline' " Status line
Plugin 'mbbill/echofunc'
Plugin 'evidens/vim-twig'
Plugin 'ap/vim-css-color'
Plugin 'airblade/vim-gitgutter' " Git status for each line
Plugin 'joonty/vdebug' " DBGP debugger
Plugin 'ervandew/supertab'
" 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 - list configured plugins
" :PluginInstall(!) - install (update) plugins
" :PluginSearch(!) foo - search (or refresh cache first) for foo
" :PluginClean(!) - confirm (or auto-approve) removal of unused plugins
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
如果是Ubuntu 15.04以前的版本,这些插件也需要通过Vundle安装:
Plugin 'scrooloose/syntastic'
Plugin 'tpope/vim-fugitive' " Git wrapper
Plugin 'kien/ctrlp.vim'" Fuzzy file, buffer, mru, tag, etc finder.
Plugin 'sirver/ultisnips'
Plugin 'honza/vim-snippets'" Snippets for snipmate
然后重新启动gVim并运行:
:PluginInstall
完成插件的最后安装
插件的配置:
编辑~/.vimrc在里面添加插件的配置:
" NERDTree
map <C-n> :NERDTreeToggle<CR>
" Tagbar
nmap <F8> :TagbarToggle<CR>
" AirLine
set laststatus=2
" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
收起回复
2楼
2015-03-09 23:27
babylgao: 这个除了Ubuntu外,可以安装到Mac os上么?
2015-4-17 03:12回复
连城go: 是直接在.virmc文件后添加就可以了吗
2015-6-5 22:53回复
这是我的完整的~/.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 'gmarik/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'spf13/PIV' " PHP Integration environment
Plugin 'majutsushi/tagbar'
Plugin 'bling/vim-airline' " Status line
Plugin 'mbbill/echofunc'
Plugin 'evidens/vim-twig'
Plugin 'ap/vim-css-color'
Plugin 'airblade/vim-gitgutter' " Git status for each line
Plugin 'joonty/vdebug' " DBGP debugger
Plugin 'ervandew/supertab'
" 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 - list configured plugins
" :PluginInstall(!) - install (update) plugins
" :PluginSearch(!) foo - search (or refresh cache first) for foo
" :PluginClean(!) - confirm (or auto-approve) removal of unused plugins
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
if has("gui_gtk2")
set guifont=DejaVu\ Sans\ Mono\ 12
end
set expandtab
set tabstop=2
set shiftwidth=2
set autoindent
set smartindent
if has("autocmd")
" Drupal *.module and *.install files.
augroup module
autocmd BufRead,BufNewFile *.module set filetype=php
autocmd BufRead,BufNewFile *.install set filetype=php
autocmd BufRead,BufNewFile *.test set filetype=php
autocmd BufRead,BufNewFile *.inc set filetype=php
autocmd BufRead,BufNewFile *.profile set filetype=php
autocmd BufRead,BufNewFile *.view set filetype=php
autocmd BufRead,BufNewFile *.theme set filetype=php
augroup END
endif
syntax on
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
let php_parent_error_close = 1
let php_parent_error_open = 1
let php_folding = 1
set number
set hlsearch
filetype indent on
set fileencodings=ucs-bom,utf-8,gbk,default,utf8
set encoding=utf-8
" NERDTree
map <C-n> :NERDTreeToggle<CR>
" Tagbar
nmap <F8> :TagbarToggle<CR>
" AirLine
set laststatus=2
" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
colorscheme desert
收起回复