经过3天的煎熬,找各种资料终于弄了个基本的符合自己vim配置。 这篇文章以后会不定时更新。 用到的插件: a.vim bufexplorer.vim color_sample_pack.vim csExplorer.vim DoxygenToolkit.vim genutils.vim list lookupfile.vim mark.vim minibufexpl.vim NERD_commenter.vim NERD_tree.vim project.vim ShowFunc.vim taglist.vim winfileexplorer.vim winmanager.vim wintagexplorer.vim vimrc文件: "display the cursor "set ruler set nocp filetype plugin on " detect the filetype " this sentence eq filetype on, filetype plugin on, filetype indent on filetype plugin indent on set nocompatible set foldmethod=syntax "set color display set t_Co=256 "Set mapleader "when use just in normal mode type ,ee let mapleader = "," "Fast reloading of the .vimrc
map "Fast editing of .vimrc
map "When .vimrc is edited, reload it autocmd! bufwritepost .vimrc source ~/.vimrc """""""""""""""""""""""""""" " MiniBufferExplorer " """""""""""""""""""""""""""" let g:miniBufExplMapWindowNavVim=1 let g:miniBufExplMapWindowNavArrows=1 let g:miniBufExplMapCTabSwitchBufs=1 "let g:miniBufExplModSelTarget=1 "进行Taglist的设置 "TlistUpdate可以更新tags
map "按下F3就可以呼出了 let Tlist_Ctags_Cmd='/usr/bin/ctags' "因为我们放在环境变量里,所以可以直接执行 let Tlist_Use_Right_Window=1 "让窗口显示在右边,0的话就是显示在左边 let Tlist_Show_One_File=1 "让taglist可以同时展示多个文件的函数列表 let Tlist_File_Fold_Auto_Close=1 "非当前文件,函数列表折叠隐藏 let Tlist_Exit_OnlyWindow=1 "当taglist是最后一个分割窗口时,自动推出vim "是否一直处理tags.1:处理;0:不处理 let Tlist_Process_File_Always=0 "不是一直实时更新tags,因为没有必要 let Tlist_Inc_Winwidth=0 "设置字体 "set guifOnt=DejaVu\ Sans\ Mono\ 10 set guifOnt=Consolas\ 11 " 开启语法高亮 syntax enable syntax on "设置了在窗口右侧何处开始换行没有\n符号,textwidth有\n set wrapmargin=10 "在代码使用4个空格代替TAB符 autocmd FileType c,cpp,py set shiftwidth=4 | set expandtab "zzg added "set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L] "set laststatus=2
"imap set shiftwidth=4 "set indent length set expandtab " set use a series of backspaces to replace tab set tabstop=4 " set when press a tab how many backspaces will skip "关闭vi兼容模式 "set nocp " 自动切换目录 set autochdir " 打开行号显示 set nu " 设置文字编码自动识别 set fencs=utf-8,cp936 " 使用鼠标 set mouse=a " 设置高亮搜索 set hlsearch " 设置代码折叠 "set fdm=indent "set foldmethod=syntax "autocmd FileType c,cpp setl fdm=syntax | setl fen " 输入字符串就显示匹配点 set incsearch " 输入的命令显示出来,看的清楚些。 set showcmd " 选择配色方案 "hi Nomal ctermfg=Grey ctermbg=Black colorscheme darkburn "colorscheme darkblue "colorscheme morning """""""""""""""""""""""""""""" " BufExplorer """""""""""""""""""""""""""""" "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. "let g:bufExplorerSplitRight=0 " Split left. "let g:bufExplorerSplitVertical=1 " Split vertically. "let g:bufExplorerSplitVertSize=30 " Split width "let g:bufExplorerUseCurrentWindow=1 " Open in new window. "autocmd BufWinEnter \[Buf\ List\] setl nonumber "打开当前目录文件列表 """""""""""""""""""""""""""""" " netrw setting """""""""""""""""""""""""""""" let g:netrw_winsize = 30
nmap let g:LookupFile_TagExpr = '"./filenametags"' """"""""""""""""""""""""""""" " WinManager setting """"""""""""""""""""""""""""" let g:winManagerWindowLayout = "FileExplorer|TagList" let g:winManagerWidth = 30 let g:defaultExplorer = 0
nmap
nmap
nmap """""""""""""""""""""""""""""" " lookupfile setting """""""""""""""""""""""""""""" let g:LookupFile_MinPatLength = 2 "最少输入2个字符才开始查找 let g:LookupFile_PreserveLastPattern = 0 "不保存上次查找的字符串 let g:LookupFile_PreservePatternHistory = 1 "保存查找历史 let g:LookupFile_AlwaysAcceptFirst = 1 "回车打开第一个匹配项目 let g:LookupFile_AllowNewFiles = 0 "不允许创建不存在的文件 if filereadable("./filenametags") "设置tag文件的名字 let g:LookupFile_TagExpr = '"./filenametags"' endif "映射LookupFile为,lk
nmap "映射LUBufs为,ll
nmap "映射LUWalk为,lw
nmap " lookup file with ignore case function! LookupFile_IgnoreCaseFunc(pattern) let _tags = &tags try let &tags = eval(g:LookupFile_TagExpr) let newpattern = '\c' . a:pattern let tags = taglist(newpattern) catch echohl ErrorMsg | echo "Exception: " . v:exception | echohl NONE return "" finally let &tags = _tags endtry " Show the matches for what is typed so far. let files = map(tags, 'v:val["filename"]') return files endfunction let g:LookupFile_LookupFunc = 'LookupFile_IgnoreCaseFunc' """""""""""""""""""""""""""""" " mark setting """"""""""""""""""""""""""""""
nmap
vmap
nmap
vmap
nmap
vmap "Quickfix hotkey
autocmd FileType c,cpp map
nmap
nmap
nmap "在当前文件中快速查找光标下的单词:
nmap
map
nmap
nmap
nmap
nmap
nmap
nmap
nmap
nmap function Do_CsTag() let dir = getcwd() if filereadable("tags") if(g:iswindows==1) let tagsdeleted=delete(dir."\\"."tags") else let tagsdeleted=delete("./"."tags") endif if(tagsdeleted!=0) echohl WarningMsg | echo "Fail to do tags! I cannot delete the tags" | echohl None return endif endif if has("cscope") silent! execute "cs kill -1" endif if filereadable("cscope.files") if(g:iswindows==1) let csfilesdeleted=delete(dir."\\"."cscope.files") else let csfilesdeleted=delete("./"."cscope.files") endif if(csfilesdeleted!=0) echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.files" | echohl None return endif endif if filereadable("cscope.out") if(g:iswindows==1) let csoutdeleted=delete(dir."\\"."cscope.out") else let csoutdeleted=delete("./"."cscope.out") endif if(csoutdeleted!=0) echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.out" | echohl None return endif endif if(executable('ctags')) "silent! execute "!ctags -R --c-types=+p --fields=+S *" silent! execute "!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ." endif if(executable('cscope') && has("cscope") ) if(g:iswindows!=1) silent! execute "!find . -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.java' -o -name '*.cs' > cscope.files" else silent! execute "!dir /s/b *.c,*.cpp,*.h,*.java,*.cs >> cscope.files" endif silent! execute "!cscope -b" execute "normal :" if filereadable("cscope.out") execute "cs add cscope.out" endif endif endfunction " OmniCppComplete let OmniCpp_NamespaceSearch = 1 let OmniCpp_GlobalScopeSearch = 1 let OmniCpp_ShowAccess = 1 let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters let OmniCpp_MayCompleteDot = 1 " autocomplete after . let OmniCpp_MayCompleteArrow = 1 " autocomplete after -> let OmniCpp_MayCompleteScope = 1 " autocomplete after :: let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] " automatically open and close the popup menu / preview window autocmd CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif " set something for ominicomplete set completeopt=longest,menu "对NERD_commenter的设置 let NERDShutUp=1
map fg :Dox let g:DoxygenToolkit_authorName="zzg"
let g:DoxygenToolkit_licenseTag="My own license\ let g:DoxygenToolkit_undocTag="DOXIGEN_SKIP_BLOCK" let g:DoxygenToolkit_briefTag_pre = "@brief\t" let g:DoxygenToolkit_paramTag_pre = "@param\t" let g:DoxygenToolkit_returnTag = "@return\t" let g:DoxygenToolkit_briefTag_funcName = "no" let g:DoxygenToolkit_maxFunctionProtoLines = 30 " mapping omini
inoremap
inoremap
inoremap
inoremap set tags+=~/.vim/stl_tags "set paste if set this the omnicomplete will not work "remember to the last position you edit zzg if has("autocmd") autocmd BufRead *.txt set tw=78 autocmd BufReadPost * \ if line("'\"") > 0 && line ("'\"") <= line("$") | \ exe "normal g'\"" | \ endif endif 总结一下安装过程中遇到的问题: 安装ctags由于以前安装过emacs,所以有了emacs的ctags,我误以为是exburant ctags已经安装了,结果错了很长时间,要安装Exburant ctags,也就是正常情况下的ctags。 安装cscope时make错误,就没安,继续往下,但是cpp的自动补全不好使。后来查到cscope缺少的相关软件有: bison , flex lib curses-dev 什么的 用 apt-cache search keywords 就能找到了.然后再安装对应的包就行了。 最后设置vim下用256色,并用了一个非常好看的颜色主题:darkburn.vim |