vim的插件管理器Vundle的使用

地址https://github.com/VundleVim/Vundle.vim

  1. 下載源碼:

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

  1. 如果~/.vim/bundle目錄不存在,則新建目錄:

cd ~
mkdir -p .vim/bundle
將下列配置放在.vimrc文件的開頭:
注意:" 表示vim配置的注釋

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()
 
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
 
" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required

如果想下載某個插件,比如自動縮進(jìn)indentpython.vim插件,需要將Plugin 'vim-scripts/indentpython.vim'置于call vundle#begin()和call vundle#end()之間,保存配置后在vim中執(zhí)行

:PluginInstall

即可以自動下載indentpython.vim插件了。

  1. bundle可以管理下載幾種不同的插件,方式如下:
  • github上的插件
    Plugin 'tpope/vim-fugitive'
  • 來自于http://vim-scripts.org/vim/scripts.html的插件
    Plugin 'L9'
  • 非github上的git插件
    Plugin 'git://git.wincent.com/command-t.git'
  • 本地插件
    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/'}
    有舊插件的情況下,下載新的插件并重命名以避免沖突
    Plugin 'ascenator/L9', {'name': 'newL9'}

下載方式除了在vim中運(yùn)行:PluginInstall外,還可以在命令行中運(yùn)行:

vim +PluginInstall +qall

其它常用的命令:

: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
  1. 安裝插件
  • 縮進(jìn)指示線

安裝:

Plugin 'Yggdroot/indentLine'

開關(guān):

:IndentLinesToggle
默認(rèn)Tab鍵是功能切換鍵
可以定義一個快捷鍵
map <C-i> :IndentLinesToggle<CR>

注意:
上邊的<C-i>表示Ctrl + i,而:IndentLinesToggle表示對應(yīng)的命令。
<CR>表示回車。

  • 自動格式化工具

地址https://github.com/Yggdroot/indentLine

首先安裝autopep8:

$ pip install autopep8

Plugin 'tell-k/vim-autopep8'

可以設(shè)置快捷鍵F8代替:Autopep8:

autocmd FileType python noremap <buffer> <F8> :call Autopep8()<CR>

注意:
:q退出當(dāng)前窗口
Ctrl + w(兩下)可以在窗口間跳動

  • 自動縮進(jìn)插件
Plugin 'vim-scripts/indentpython.vim'
  • 語法檢查
Plugin 'vim-syntastic/syntastic'
  • 配色方案
Plugin 'altercation/vim-colors-solarized'

syntax enable
set background=light 或者 dark
colorscheme solarized
  • 樹形目錄
Plugin 'scrooloose/nerdtree'

開關(guān)樹形目錄的快捷鍵:
map <C-n> :NERDTreeToggle<CR>

注意:
上邊的<C-n>表示Ctrl + n,而:NERDTreeToggle表示對應(yīng)的命令。
<CR>表示回車。

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

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

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