VIM學習二: VIM配置代碼及效果圖

vim學習及插件

參見:http://www.cnblogs.com/caixu/p/6337926.htmlhtml

.vimrc配置

"**********************************************
"*****************Part1 Base *****************
"**********************************************
"關閉兼容模式, 即不要使用vi的鍵盤模式
set nocompatible c++

 
 

"設置行號顯示與否
set nu
"設置自動縮進
set autoindent
"設置縮進寬度
set shiftwidth=4
"爲C程序提供自動縮進
set smartindent vim

 
 

"設置全部的Tab和縮進爲4和空格
set tabstop=4
"使得按退格鍵一次能夠刪除4個空格
set softtabstop=4學習

 
 

"設置 C/C++ 語言的具體縮進方式
"set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1sui

 
 

"設置退格
"set backspace=indent,eol,start編碼

 
 

"激活鼠標的使用
set mouse=aspa

 
 

"molokai原始背景色
let g:molokai_original = 1
"設置molokai
let g:rehash256 = 1
"vim開啓256色支持
set t_Co=256
"設置顏色
"colorscheme desert
colorscheme molokai
"設置背景色
set background=dark插件

 
 


"當文件在外部被更改時,自動更新該文件
"set autoread rest

 
 

"顯示匹配的括號
"set showmatchcode

 
 

"解決複製粘帖格式錯亂問題
set paste
"set pastetoggle=<F9>

 
 

"開啓語法
set syntax=on

 
 

"偵測文件類型
filetype on
"載入文件類型插件
filetype plugin on
"爲特定文件類型載入相關縮進文件
filetype indent on

 
 

"搜索時高亮顯示搜索到的內容
set hlsearch
"在搜索時,輸入的詞句的逐字符高亮
set incsearch
"高亮顯示當前行
set cursorline

 
 

"設置按照語法摺疊 syntax:用語法高亮來定義摺疊
set foldmethod=syntax
"設置折層數
set foldlevel=100
"設置摺疊區域的寬度
set foldcolumn=2

 
 

"設置編碼
set encoding=utf-8
"設置終端編碼
set termencoding=utf-8
"設置文件編碼
set fileencoding=gb2312
"按順序使用fileencodings 中的編碼進行嘗試解碼, 解決文件編碼識別與亂碼處理
set fileencodings=ucs-bom,utf-8,cp936,ansi,prc

 
 

"搜索時不區分大小寫
"set ignorecase

 
 

"支持跨行移動或者刪除
set whichwrap=b,s,<,>,[,]

 
 

"在命令模式下使用 Tab 自動補全的時候,將補全內容使用一個漂亮的單行菜單形式顯示出來
set wildmenu

 
 

"設置狀態行格式
set statusline=%<[%F]%y%r%m%*%=[%l,%c][%p%%]
"顯示狀態欄, 默認值爲1:表示沒法顯示狀態欄
"set laststatus=2
"設置在編輯過程當中右下角顯示光標的行列信息
set ruler
"在左下角的狀態欄顯示 --INSERT-- 之類的字眼
set showmode

 
 


"**********************************************
"*****************Part2 Plugin*****************
"**********************************************
"======ctags
map <F5> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
map <F2> :cw<CR>
map <F3> :ccl<CR>
set tags=tags;/

 
 

"ctrl-] jump to the function definition
"ctrl-t or ctrl-o jump to the laster pointer position

 
 

"======taglist
"不一樣時顯示多個文件的tag,僅顯示一個
let Tlist_Show_One_File=1
"taglist爲最後一個窗口時,退出vim
let Tlist_Exit_OnlyWindow=1

 
 

"======cscope
"ctrl-\s find string include declare
"ctrl-\c find all call, not include declare
"把Cscope的查找結果輸出到quickfix窗口
set cscopequickfix=s-,g-,c-,d-,i-,t-,e-

 
 

"======Winmanager, NERDTree, MiniBufExplorer
"能夠用<C-h,j,k,l>切換到上下左右的窗口
let g:miniBufExplMapWindowNavVim = 1
"是用<C-箭頭鍵>切換到上下左右窗口中去
let g:miniBufExplMapWindowNavArrows = 1
"<C-Tab>,<C-S-Tab>切換
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
let g:miniBufExplMoreThanOne=0

 
 

let g:NERDTree_title="[NERDTree]"
let g:winManagerWindowLayout="NERDTree|TagList"

function! NERDTree_Start()
exec 'NERDTree'
endfunction

function! NERDTree_IsValid()
return 1
endfunction

nmap wm :WMToggle<CR>

 
 

 

 
 

"function! Zoom ()
" " check if is the zoomed state (tabnumber > 1 && window == 1)
" if tabpagenr('$') > 1 && tabpagewinnr(tabpagenr(), '$') == 1
" let l:cur_winview = winsaveview()
" let l:cur_bufname = bufname('')
" tabclose
"
" " restore the view
" if l:cur_bufname == bufname('')
" call winrestview(cur_winview)
" endif
" else
" tab split
" endif
"endfunction

 

顯示效果圖:

相關文章
相關標籤/搜索