(轉)Vim 配置文件===/etc/vimrc
"=============================================================================== " Filename: vimrc " Author:myswirl " Email:myswirl@163.com " Created: 2009-04-28 "=============================================================================== set fileencodings=ucs-bom,utf-8,cp936 " 打開文件時會根據fileencodings選項來識別文件編碼 set fileencoding=utf-8 " 保存新建文件時會根據fileencoding的設置編碼來保存 set encoding=utf-8 " Vim的內部使用編碼 set termencoding=utf-8 " Vim終端所使用的編碼 set guifont=Luxi/ Mono/ 9 " 設置字體,字體名稱和字號 set tabstop=4 " 設置tab鍵的寬度 set backspace=2 " 設置退格鍵可用 set nu " 顯示行號 set nocompatible "去掉vim的兼容性bug "set vbt_vb= " vim進行編輯時,如果命令錯誤,會發出一個響聲,該設置去掉響聲 "set wrap " 自動換行 "set nowrap " 不自動換行 set linebreak " 整詞換行 set whichwrap=b,s,<,>,[,] " 光標從行首和行末時可以跳到另一行去 "set list " 顯示制表符 "set listchars = tab:>-,trail:- " 將制表符顯示為'>---',將行尾空格顯示為'-' set listchars=tab:./ ,trail:. " 將制表符顯示為'. ' "set autochdir " 自動設置目錄為正在編輯的文件所在的目錄 set hidden " 沒有保存的緩沖區可以自動被隱藏 set scrolloff=5 " "-------------------------------------------------------------------------------- " 查找/替換相關的設置 "-------------------------------------------------------------------------------- set hlsearch " 高亮顯示搜索結果 set incsearch " 查詢時非常方便,如要查找book單詞,當輸入到/b時,會自動找到 " 第一個b開頭的單詞,當輸入到/bo時,會自動找到第一個bo開頭的 " 單詞,依次類推,進行查找時,使用此設置會快速找到答案,當你 " 找要匹配的單詞時,別忘記回車 set gdefault " 替換時所有的行內匹配都被替換,而不是只有第一個 "-------------------------------------------------------------------------------- " 狀態欄相關的設置 "-------------------------------------------------------------------------------- set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%] set laststatus=2 " always show the status line set ruler " 在編輯過程中,在右下角顯示光標位置的狀態行 "-------------------------------------------------------------------------------- " 編程相關的設置 "-------------------------------------------------------------------------------- "set completeopt=longest,menu " 關掉智能補全時的預覽窗口 filetype plugin indent on " 加了這句才可以用智能補全 :set tags=/home/mingyang/ipmsg/tags syn on " 打開語法高亮 set showmatch " 設置匹配模式,類似當輸入一個左括號時會匹配相應的那個右括號 set smartindent " 智能對齊方式 set shiftwidth=4 " 換行時行間交錯使用4個空格 set autoindent " 自動對齊 set ai! " 設置自動縮進 colorscheme desert " 配色方案/usr/share/vim/vim63/colors "-------------------------------------------------------------------------------- " 代碼折疊 "-------------------------------------------------------------------------------- "set foldmarker={,} set foldmethod=syntax " maker syntax set foldlevel=100 " Don't autofold anything (but I can still fold manually) "set foldopen-=search " don't open folds when you search into them "set foldopen-=undo " don't open folds when you undo stuff "set foldcolumn=4 " "-------------------------------------------------------------------------------- " 模仿MS Windows中的快捷鍵 "-------------------------------------------------------------------------------- vmap <C-c> "yy vmap <C-x> "yd nmap <C-v> "yp vmap <C-v> "yp nmap <C-a> ggvG$ " "-------------------------------------------------------------------------------- " 窗口操作的快捷鍵 "-------------------------------------------------------------------------------- nmap wv <C-w>v " 垂直分割當前窗口 nmap wc <C-w>c " 關閉當前窗口 nmap ws <C-w>s " 水平分割當前窗口 "-------------------------------------------------------------------------------- " 模仿MS Windows中的保存命令: Ctrl+S "-------------------------------------------------------------------------------- imap <C-s> <Esc>:wa<cr>i<Right> nmap <C-s> :wa<cr> "############################################################################### " The following is the Plugins' setting "############################################################################### "-------------------------------------------------------------------------------- " TagList :Tlist "-------------------------------------------------------------------------------- let Tlist_Show_One_File= 1 " let Tlist_Exit_OnlyWindow = 1 " let Tlist_Use_Right_Window=1 " "-------------------------------------------------------------------------------- " netrw 文件瀏覽器 :e <PATH> "-------------------------------------------------------------------------------- "let g:netrw_winsize = 20 " 瀏覽器寬度 "-------------------------------------------------------------------------------- " QuickFix "-------------------------------------------------------------------------------- nmap <F6> :cn<cr> " 切換到下一個結果 nmap <F7> :cp<cr> " 切換到上一個結果 "-------------------------------------------------------------------------------- " WinManager :WMToggle "-------------------------------------------------------------------------------- let g:winManagerWindowLayout= 'FileExplorer|TagList' " let g:winManagerWidth = 20 " let g:defaultExplorer = 0 " nmap <C-w><C-b> :BottomExplorerWindow<cr> " 切換到最下面一個窗格 nmap <C-w><C-f> :FirstExplorerWindow<cr> " 切換到最上面一個窗格 nmap wm:WMToggle<cr> " 輸入命令:WMToggle打開 "-------------------------------------------------------------------------------- " MiniBufExp "-------------------------------------------------------------------------------- "let g:miniBufExplMapWindowNavVim = 1 "let g:miniBufExplMapWindowNavArrows = 1 "let g:miniBufExplMapCTabSwitchBufs = 1 "let g:miniBufExplModSelTarget = 1 "-------------------------------------------------------------------------------- " cscope "-------------------------------------------------------------------------------- cs add /home/nfs/microwindows/src/cscope.out /home/nfs/microwindows/src ":set cscopequickfix=s-,c-,d-,i-,t-,e- ":set cscopetag " 按下面這種組合鍵有技巧,按了<C-_>后要馬上按下一個鍵,否則屏幕一閃 " 就回到nomal狀態了 " <C-_>s的按法是先按"Ctrl+Shift+-",然后很快再按"s" nmap <C-_>s :cs find s <C-R>=expand("<cword>")<cr><cr> :cw<cr> nmap <C-_>g :cs find g <C-R>=expand("<cword>")<cr><cr> :cw<cr> nmap <C-_>c :cs find c <C-R>=expand("<cword>")<cr><cr> :cw<cr> nmap <C-_>t :cs find t <C-R>=expand("<cword>")<cr><cr> :cw<cr> nmap <C-_>e :cs find e <C-R>=expand("<cword>")<cr><cr> :cw<cr> nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<cr><cr> nmap <C-_>i :cs find i <C-R>=expand("<cfile>")<cr><cr> :cw<cr> nmap <C-_>d :cs find d <C-R>=expand("<cword>")<cr><cr> :cw<cr> "-------------------------------------------------------------------------------- " Grep "-------------------------------------------------------------------------------- "直接按下<F3>鍵來查找光標所在的字符串 nnoremap <silent> <F3> :Rgrep<CR> "-------------------------------------------------------------------------------- " A "-------------------------------------------------------------------------------- nnoremap <silent> <F12> :A<CR> "-------------------------------------------------------------------------------- " NERD_commenter "-------------------------------------------------------------------------------- let NERD_c_alt_style = 1 " 將C語言的注釋符號改為//, 默認是/**/ "nmap <F5> ,cc "-------------------------------------------------------------------------------- " SuperTab :SuperTabHelp "-------------------------------------------------------------------------------- "let g:SuperTabRetainCompletionType = 2 "let g:SuperTabDefaultCompletionType = "<C-X><C-O>" "-------------------------------------------------------------------------------- " CVim :help csupport "-------------------------------------------------------------------------------- let g:C_Comments = "no" " 用C++的注釋風格 let g:C_BraceOnNewLine = "no" " '{'是否獨自一行 let g:C_AuthorName= "Lmy" " let g:C_Project= 'F9' " let g:Cpp_Template_Function = "c-function-description-Lmy" " let g:C_TypeOfH = "c" " *.h文件的文件類型是C還是C++ "################################################################## "########################## End Of Vimrc ########################## "################################################################## " if filetype is C " TODO " fi