1.先安装vundle
vundle的安装方法很简单,具体如下:
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/Vundle.vim
2. 接下来在~/.vimrc文件中加入下面内容:
该配置文件转自csdn中的博客
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
" plugins
Plugin 'scrooloose/nerdtree'
Plugin 'bling/vim-airline'
Plugin 'mattn/emmet-vim'
Plugin 'godlygeek/tabular'
Plugin 'Shougo/neocomplcache.vim'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'kien/ctrlp.vim'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'tpope/vim-commentary'
Plugin 'jiangmiao/auto-pairs'
Plugin 'jQuery'
Plugin 'othree/html5.vim'
call vundle#end() " required
filetype plugin indent on " required
" settings
syntax enable
syntax on
let mapleader=','
let g:molokai_original = 1
let g:rehash256 = 1
set t_Co=256
colorscheme molokai
set termencoding=utf-8
set encoding=utf8
set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030
set cul
set laststatus=2
set number
set noshowmode
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set smarttab
set autoindent
set smartindent
set ruler
set ignorecase
set hls
set foldmethod=syntax
set showcmd
" backup
set nobackup
set nowb
set noswapfile
" search
set hlsearch
set incsearch
" backspace
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" javascript settings
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
" html5 settings
let g:html5_event_handler_attributes_complete = 0
" nerdtree settings
autocmd vimenter * NERDTree
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
map <silent> <F2> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" airline settings
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
" ctags settings
let Tlist_Ctags_Cmd ='/usr/local/Cellar/ctags/5.8/bin/ctags' "这里比较重要了,设置ctags的位置,不是指向MacOS自带的那个,而是我们用homebrew安装的那个,Centos下配置注销这行即可。
" taglist settings
let Tlist_Use_Right_Window = 1 "让taglist窗口出现在Vim的右边
let Tlist_File_Fold_Auto_Close = 1 "当同时显示多个文件中的tag时,设置为1,可使taglist只显示当前文件tag,其它文件的tag都被折叠起来。
let Tlist_Show_One_File = 1 "只显示一个文件中的tag,默认为显示多个
let Tlist_Sort_Type ='name' "Tag的排序规则,以名字排序。默认是以在文件中出现的顺序排序
let Tlist_GainFocus_On_ToggleOpen = 1 "Taglist窗口打开时,立刻切换为有焦点状态
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_WinWidth = 32 "设置窗体宽度为32,可以根据自己喜好设置
map <silent> <F9> :TlistToggle <CR>
" emment settings
let g:user_emmet_mode='n' "only enable normal mode functions.
let g:user_emmet_mode='inv' "enable all functions, which is equal to
let g:user_emmet_mode='a' "enable all function in all mode.
let g:emmet_html5 = 0
let g:user_emmet_install_global = 0
autocmd FileType html,css EmmetInstall
" let g:user_emmet_leader_key='<C-Z>'
" let g:user_emmet_expandabbr_key='<Tab>'
" neocompletecache settings
let g:acp_enableAtStartup = 0
let g:neocomplcache_enable_at_startup = 1
let g:neocomplcache_enable_smart_case = 1
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
inoremap <expr><C-g> neocomplcache#undo_completion()
inoremap <expr><C-l> neocomplcache#complete_common_string()
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplcache#close_popup()
inoremap <expr><C-e> neocomplcache#cancel_popup()
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" ctrlp settings
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " Linux/MacOSX
let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
3. 接下来打开vim,输入:BundleInstall就可以完成插件的安装了。
后续增加新的vim插件,到vimrc文件中加入 Plugin 'xxx',再打开vim,输入:BundleInstall就好了。
Vundle常用命令:
:BundleList 列出已经安装的插件
:BundleInstall 安装所有配置文件中的插件
:BundleInstall! 更新所有插件
:BundleSearch 搜索插件
:BundleClean! 根据配置文件删除插件
4. 配色方案 molokai
配置方案中有个molokai(https://github.com/tomasr/molokai
)的配色方案,和sublime text3 上的配色一样,下载colors文件夹,将molokai.vim 复制到~/.vim/colors 中即可。
5. 常用插件
ndtree
主要功能是一款文件浏览器,可以查看文件目录结构打开相应的文件。
Vundel 安装方法:
Plugin 'scrooloose/nerdtree'
ctrlp
就像名字它的快捷键就是ctrl+p 实现快速查找文件。
Vundel 安装方法:
Plugin 'kien/ctrlp.vim'
Emment
过去是zencoding,非官方插件会有一些奇怪的bug。
默认快捷键 ctrl+y+,
Vundel 安装方法:
Plugin 'emmetio/emmet'
html5
支持html5标签
Vundel 安装方法:
Plugin 'bling/vim-airline'
taglist
centos下先安装ctags
yum install ctags
然后配置ctags的路径
" ctags settings let Tlist_Ctags_Cmd ='/usr/bin/ctags'
文章参考自CSDN中的博客.