vimrc /etc/vim/vimrc
runtime! debian.vim if has("syntax") syntax on endif if filereadable("/etc/vim/vimrc.local") source /etc/vim/vimrc.local endif set guifont=DejaVu\ Sans\ mono\ book \ 11 "设置默认目录 cd /home/trylen/code "传说中的去掉边框用下边这一句 set go= "设置配色,这里选择的是desert,也有其他方案,在vim中输入:color 在敲tab键可以查看 color desert "设置背景色,每种配色有两种方案,一个light、一个dark set background=light "打开语法高亮 syntax on "显示行号 set number "设置缩进有三个取值cindent(c风格)、smartindent(智能模式,其实不觉得有什么智能)、autoindent(简单的与上一行保持一致) set cindent "在windows版本中vim的退格键模式默认与vi兼容,与我们的使用习惯不太符合,下边这条可以改过来 set backspace=indent,eol,start "用空格键替换制表符 :set expandtab "制表符占4个空格 set tabstop=4 "默认缩进4个空格大小 set shiftwidth=4 "增量式搜索,比如键入"/bo",光标会自动找到第一个"bo"所在的位置 set incsearch "符号匹配,一下出两个括号 set showmatch "高亮搜索 set hlsearch "有时中文会显示乱码,用一下几条命令解决 let &termencoding=&encoding set fileencodings=utf-8,gbk "很多插件都会要求的配置检测文件类型 filetype on filetype plugin on filetype indent on "下边这个很有用可以根据不同的文件类型执行不同的命令 "例如:如果是c/c++类型 :autocmd FileType c,cpp : set foldmethod=syntax :autocmd FileType c,cpp :set number :autocmd FileType c,cpp :set cindent "例如:如果是python类型 :autocmd FileType python :set number :autocmd FileType python : set foldmethod=syntax :autocmd FileType python :set smartindent map <F9> :call CompileGcc()<CR> func! CompileGcc() if&filetype == 'c' exec "w" exec "!gcc % -o %<" elseif &filetype == 'cpp' exec "w" exec "!g++ % -o %<" endif endfunc map <F10> :call RunGcc()<CR> func! RunGcc() exec "! ./%<" endfunc let g:neocomplcache_enable_at_startup = 1 "-- omnicppcomplete setting -- set tags+=~/.vim/tags/cpp 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 let OmniCpp_DisplayMode=1 let OmniCpp_DefaultNamespaces=["std"]