vim 插件配置整理

1、插件管理器

Vundle是一個流行的vim插件管理器,它的網址是https://github.com/VundleVim/Vundle.vim

以下是安裝步驟:

  1. git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
    如果目錄.vim/bundle不存在請先創建
  2. 打開~/.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 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
"Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
"Plugin 'L9'
" Git plugin not hosted on GitHub
"Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"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/'}
" Avoid a name conflict with L9
"Plugin 'user/L9', {'name': 'newL9'}

" 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       - 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
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  1. 從其中的註釋可以知道,Vundle支持多種形式的插件源,並給出了示例。這些插件源包括:github上的插件、http://vim-scripts.org/vim/scripts.html上的插件、非github上的git插件、本地硬盤上的插件等。

  2. 打開vim,運行 :PluginInstall 命令來自動安裝插件,過程中有可能需要輸入github用戶名和密碼。等待Vundle安裝完成即可。

Vundle正在自動安裝在.vimrc中指定的插件:

 

2、Doxygen註釋自動生成

爲自己的代碼寫好註釋是一個良好的習慣,而編寫Doxygen風格的註釋更是可以通過doxygen工具爲代碼自己生成文檔,非常好用。DoxygenToolkit(https://github.com/vim-scripts/DoxygenToolkit.vim)就是這樣的一個插件。安裝和使用:

  1. 在~/.vimrc中的Vundle插件列表區域中添加DoxygenToolkit的源位置
    Plugin 'vim-scripts/DoxygenToolkit.vim'
    保存後退出,再打開vim,運行:PluginInstall命令安裝
  2. 在~.vimrc中,Vundle區域後的某處,設置DoxygenToolkit插件在@author區域自動填充的作者名稱,比如
let g:DoxygenToolkit_authorName="author" 
  1. 使用時,將光標定位到文件首行,輸入:DoxAuthor將插入文件頭註釋骨架(第一次會讓你輸入文件版本號);
  2. 並把光標停留在@brief 後面,等待輸入文件描述。在光標定位到數據結構聲明或函數聲明的第一行,運行:Dox,將生成數據結構或函數的註釋骨架;

3、nerdtree樹形目錄

在.vimrc中加入

Bundle 'The-NERD-tree'
Bundle 'The-NERD-Commenter'

然後執行 
vim
然後執行安裝命令
:BundleInstall

使用命令

:NERDTree  進入樹形界面
:NERDTreeToggle  關閉樹形

設置默認開啓  .vimrc中添加  autocmd VimEnter * NERDTree

顯示與隱藏
map <F3> :NERDTreeMirror<CR>
map <F3> :NERDTreeToggle<CR>


常用命令
和編輯文件一樣,通過h j k l移動光標定位
打開關閉文件或者目錄,如果是文件的話,光標出現在打開的文件中
go 效果同上,不過光標保持在文件目錄裏,類似預覽文件內容的功能
i和s可以水平分割或縱向分割窗口打開文件,前面加g類似go的功能
t 在標籤頁中打開
T 在後臺標籤頁中打開
ctrl+w+w 光標在左右窗口切換
ctrl+w+r 切換當前窗口左右佈局
ctrl+p 模糊搜索文件
gT 切換到前一個tab
g t 切換到後一個tab
p 到上層目錄
P 到根目錄
K 到同目錄第一個節點
J 到同目錄最後一個節點
m 顯示文件系統菜單(添加、刪除、移動操作)
r: 刷新光標所在的目錄
R: 刷新當前根路徑
? 幫助
q 關閉

參考:

https://www.jianshu.com/p/58de4d7109d6

https://www.cnblogs.com/zzqcn/p/4660615.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章