CentOS6 下Vim安装和配置
生活随笔
收集整理的這篇文章主要介紹了
CentOS6 下Vim安装和配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.系統只安裝了vim-minimal,執行以下命令安裝另外兩個組件
yum install vim-common yum install vim-enhanced2.安裝ctags
yum install ctags? ?下載linux-2.6.32.27內核源碼并解壓到~/arm/linux-2.6.32.27,進入該目錄,生成索引文件
ctags -R *3.安裝插件(基本上就是解壓到~/.vim目錄):taglist/nerdcommenter/omnicppcomplete/echofunc/bufexplorer/winmanager
4.配置文件
" 關閉vi的鍵盤模式 set nocompatible " 關閉備份 set nobackup " 禁止生成臨時文件 set noswapfile" 允許使用鼠標定位和選擇 set mouse=a set selection=exclusive set selectmode=mouse,key" 顯示行號 set number " 禁止折行 set nowrap" 突出顯示當前行 "set cursorline cursorcolumn" 切換文件時自動保存當前改動文件 set autowrite" 設置狀態欄顯示的內容 "set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} " 設置總是顯示狀態欄 "set laststatus=2" 光標移動到頂部和底部時保持3行距離 set scrolloff=3" 檢測文件類型 filetype on filetype plugin on" 設置編碼 set encoding=utf-8 set termencoding=utf-8 set fileencodings=ucs-bom,utf-8,gbk,gb2312,cp936 set fileencoding=utf-8" 設置語言 set langmenu=zh_CN.UTF-8 set helplang=cn" 設置tab set noexpandtab " 不將tab擴展成空格 set tabstop=2 " 一個tab顯示出來是多少個空格 set shiftwidth=2 " 每一級縮進多少個空格 set smarttab " 根據文件中其他地方的縮進空格個數來確定一個tab是多少個空格" 設置縮進 set nocindent " 關閉cindent縮進方式 "set cindent " 開啟C/C++語言的縮進方式 "set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s " 設置C/C++語言的具體縮進方式 set noautoindent " 關閉autoindent縮進方式 set nosmartindent " 關閉smartindent縮進方式if has("autocmd")filetype plugin indent onautocmd FileType text setlocal textwidth=78autocmd FileType text set nocindentautocmd FileType html set formatoptions+=tlautocmd FileType css set smartindentautocmd FileType c,cpp,slang,esqlc set cindent endif" 語法高亮 syntax enable syntax on" 設置配色 colorscheme desert "colorscheme darkblue "colorscheme peachpuff" 搜索忽略大小寫 set ignorecase " 如果搜索模式包含大寫字母則忽略'ignorecase'選項 set smartcase " 搜索逐字符高亮 set hlsearch set incsearch" 高亮顯示匹配的括號 set showmatch " 匹配括號高亮的時間(單位是十分之一秒) set matchtime=1" --ctags settings-- map <F12> :!ctags -R --c++-kinds=+p --fields=+ialS --extra=+q .<CR><CR> :TlistUpdate<CR> imap <F12> <ESC>:!ctags -R -c++kinds=+p --fields=+ialS --extra=+q .<CR><CR> :TlistUpdate<CR> set tags=tags set tags+=~/arm/linux-2.6.32.27/tags " add the linux kernel source's tags file set tags+=./tags " add current directory's generated tags file" --OmniCppComplete settings-- imap<F3> <C-X><C-O> set completeopt=menu,menuone " 關閉智能補全時的預覽窗口 let OmniCpp_MayCompleteDot=1 " autocomplete with . let OmniCpp_MayCompleteArrow=1 " autocomplete with -> let OmniCpp_MayCompleteScope=1 " autocomplete with :: let OmniCpp_SelectFirstItem=2 " select first item, but don't insert let OmniCpp_NamespaceSearch=2 " search namespaces in this and included files let OmniCpp_ShowPrototypeInAbbr=1 " show function prototype in popup window let OmniCpp_GlobalScopeSearch=1 " enable the global scope search let OmniCpp_DisplayMode=1 " class scope completion mode: always show all members "let OmniCpp_DefaultNamespaces=["std"] let OmniCpp_ShowScopeInAbbr=1 " show scope in abbreviation and remove the last column let OmniCpp_ShowAccess=1" --Taglist settings-- let Tlist_Ctags_Cmd='ctags' let Tlist_Use_Right_Window=1 let Tlist_Show_One_File=0 " 允許同時顯示多個文件的函數列表 let Tlist_File_Fold_Auto_Close=1 " 非當前文件,函數列表折疊隱藏 let Tlist_Exit_OnlyWindow=1 " 當Taglist是最后一個分割窗口時,自動退出vim let Tlist_Process_File_Always=1 " 實時更新tags let Tlist_Inc_Winwidth=0 let Tlist_WinWidth=40 "nmap tl :Tlist<CR>" --BufExplorer settings-- let g:bufExplorerDefaultHelp=0 " Do not show default help. let g:bufExplorerShowRelativePath=1 " Show relative paths. let g:bufExplorerSortBy='mru' " Sort by most recently used." --WinManager setting-- let g:winManagerWindowLayout='BufExplorer|FileExplorer' " 設置我們要管理的插件 let g:persistentBehaviour=0 " 如果所有編輯文件都關閉了,退出vi let g:winManagerWidth=30 nmap wm :TlistToggle<CR> :WMToggle<CR>" --QuickFix settings-- "map <F7> :make<CR> :copen<CR> "map <F8> :cp<CR> "map <F9> :cn<CR> "imap <F7> <ESC>:make<CR> :copen<CR> "imap <F8> <ESC>:cp<CR> "imap <F9> <ESC>:cn<CR>" --Fold settings-- function! ToggleFold()if foldlevel('.')==0normal! lelseif foldclosed('.')<0. foldclose!else. foldopen!endifendif" clear status lineecho endfunctionnoremap <space> :call ToggleFold()<CR>function FoldBrace()if getline(v:lnum+1)[0]=='{'return 1endifif getline(v:lnum)=~'{'return 1endifif getline(v:lnum)[0]=~'}'return '<1'endifreturn -1 endfunctionif has("autocmd")autocmd BufReadPost *.h,*.hh,*.c,*.ec,*.cpp,*.hpp,*.ecpp,*.pc set foldexpr=FoldBrace()autocmd BufReadPost *.h,*.hh,*.c,*.ec,*.cpp,*.hpp,*.ecpp,*.pc set foldmethod=exprautocmd BufReadPost *.h,*.hh,*.c,*.ec,*.cpp,*.hpp,*.ecpp,*.pc set foldenable endif" --Terminal color settings-- hi Folded term=standout cterm=bold ctermfg=DarkGreen ctermbg=NONE hi IncSearch term=bold ctermfg=red ctermbg=black hi Search term=bold ctermfg=red ctermbg=black?
轉載于:https://www.cnblogs.com/codingthings/p/4698895.html
總結
以上是生活随笔為你收集整理的CentOS6 下Vim安装和配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux网络流量实时监控ifstat
- 下一篇: KVO 和 KVC 的区别?