Vim插件管理

1.先安裝vundle

vundle的安裝方法很簡(jiǎn)單,具體如下:
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/Vundle.vim

2. 接下來在~/.vimrc文件中加入下面內(nèi)容:

該配置文件轉(zhuǎn)自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'  "這里比較重要了,設(shè)置ctags的位置,不是指向MacOS自帶的那個(gè),而是我們用homebrew安裝的那個(gè),Centos下配置注銷這行即可。

" taglist settings
let Tlist_Use_Right_Window = 1 "讓taglist窗口出現(xiàn)在Vim的右邊
let Tlist_File_Fold_Auto_Close = 1 "當(dāng)同時(shí)顯示多個(gè)文件中的tag時(shí),設(shè)置為1,可使taglist只顯示當(dāng)前文件tag,其它文件的tag都被折疊起來。
let Tlist_Show_One_File = 1 "只顯示一個(gè)文件中的tag,默認(rèn)為顯示多個(gè)
let Tlist_Sort_Type ='name' "Tag的排序規(guī)則,以名字排序。默認(rèn)是以在文件中出現(xiàn)的順序排序
let Tlist_GainFocus_On_ToggleOpen = 1 "Taglist窗口打開時(shí),立刻切換為有焦點(diǎn)狀態(tài)
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一個(gè)窗口,則退出vim
let Tlist_WinWidth = 32 "設(shè)置窗體寬度為32,可以根據(jù)自己喜好設(shè)置
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就可以完成插件的安裝了。

后續(xù)增加新的vim插件,到vimrc文件中加入 Plugin 'xxx',再打開vim,輸入:BundleInstall就好了。

Vundle常用命令:

:BundleList 列出已經(jīng)安裝的插件
:BundleInstall 安裝所有配置文件中的插件
:BundleInstall! 更新所有插件
:BundleSearch 搜索插件
:BundleClean! 根據(jù)配置文件刪除插件

4. 配色方案 molokai

配置方案中有個(gè)molokai(https://github.com/tomasr/molokai
)的配色方案,和sublime text3 上的配色一樣,下載colors文件夾,將molokai.vim 復(fù)制到~/.vim/colors 中即可。

5. 常用插件

ndtree

主要功能是一款文件瀏覽器,可以查看文件目錄結(jié)構(gòu)打開相應(yīng)的文件。
Vundel 安裝方法:
Plugin 'scrooloose/nerdtree'

ctrlp

就像名字它的快捷鍵就是ctrl+p 實(shí)現(xiàn)快速查找文件。
Vundel 安裝方法:
Plugin 'kien/ctrlp.vim'

Emment

過去是zencoding,非官方插件會(huì)有一些奇怪的bug。
默認(rèn)快捷鍵 ctrl+y+,
Vundel 安裝方法:
Plugin 'emmetio/emmet'

html5

支持html5標(biāo)簽
Vundel 安裝方法:
Plugin 'bling/vim-airline'

taglist

centos下先安裝ctags
yum install ctags
然后配置ctags的路徑
" ctags settings let Tlist_Ctags_Cmd ='/usr/bin/ctags'

文章參考自CSDN中的博客.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容