"------------------------------------------------------------------------------- "使用quickfix显示结果 "------------------------------------------------------------------------------- set cscopequickfix=s-,c-,d-,i-,t-,e- "------------------------------------------------------------------------------- "基本设置 "------------------------------------------------------------------------------- set tabstop=4 " 设置tab键的宽度 set backspace=2 " 设置退格键可用 set nu! " 显示行号 "set wrap " 自动换行 set nowrap " 不自动换行 set linebreak " 整词换行 set whichwrap=b,s,<,>,[,] " 光标从行首和行末时可以跳到另一行去 set showmatch " 设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号 set smartindent " 智能对齐方式 set shiftwidth=4 " 换行时行间交错使用4个空格 set autoindent " 自动对齐 set cindent "设置支持c语言缩进 set expandtab "非常重要的设置,把tab变成4个空格 "set cursorline "突出显示当前行 set showcmd "状态栏显示键盘按键 set mouse=v "-------------------------------------------------------------------------------- " 设置在状态行显示的信息 "-------------------------------------------------------------------------------- set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏) set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\ "-------------------------------------------------------------------------------- " 查找/替换相关的设置 "-------------------------------------------------------------------------------- set hlsearch " 高亮显示搜索结果 set incsearch " 查询时非常方便,如要查找book单词,当输入到/b时,会自动找到 " 第一个b开头的单词,当输入到/bo时,会自动找到第一个bo开头的 " 单词,依次类推,进行查找时,使用此设置会快速找到答案,当你 " 找要匹配的单词时,别忘记回车 set gdefault " 替换时所有的行内匹配都被替换,而不是只有第一个 nmap <F3> :nohlsearch<CR> "------------------------------------------------------------------------------- "颜色主题 "------------------------------------------------------------------------------- "colorscheme desert colorscheme morning "------------------------------------------------------------------------------- "高亮显示 "------------------------------------------------------------------------------- syntax on syntax enable "------------------------------------------------------------------------------- "支持粘帖 和插入模式光标移动冲突 "------------------------------------------------------------------------------- "set paste "支持粘帖 "------------------------------------------------------------------------------- "中文显示 "------------------------------------------------------------------------------- set fileencodings=utf-8,gb2312,gbk,gb18030 set termencoding=utf-8 set fileformats=unix set encoding=prc "------------------------------------------------------------------------------- "窗口操作快捷键 "------------------------------------------------------------------------------- nmap wv <C-w>v " 垂直分割当前窗口 nmap wc <C-w>c " 关闭当前窗口 nmap ws <C-w>s " 水平分割当前窗口<S-F12> "-------------------------------------------------------------------------------- " 模仿MS Windows中的保存命令: Ctrl+S "------------------------------------------------------------------------------- "imap <C-s> <Esc>:wa<cr>i<Right> imap <C-s> <Esc>:wa<cr> map <C-s> :wa<cr> "-------------------------------------------------------------------------------- " QuickFix "-------------------------------------------------------------------------------- nmap <F6> :cn<cr> " 切换到下一个结果 nmap <F7> :cp<cr> " 切换到上一个结果 "-------------------------------------------------------------------------------- "c/h文件间相互切换 -- 插件: A "-------------------------------------------------------------------------------- nnoremap <silent> <F12> :A<CR> "-------------------------------------------------------------------------------- " echo fun cmd "-------------------------------------------------------------------------------- "ctags -R --fields=+lS "-------------------------------------------------------------------------------- " taglist "-------------------------------------------------------------------------------- let Tlist_Show_One_File=1 let Tlist_Exit_OnlyWindow=1 "let Tlist_Use_Right_Window=1 "-------------------------------------------------------------------------------- "通过WinManager插件来将TagList窗口和netrw窗口整合起来 "-------------------------------------------------------------------------------- let g:winManagerWindowLayout='TagList' "let g:winManagerWindowLayout='FileExplorer|TagList' "let g:winManagerWindowLayout='NERDTree|TagList,BufExplorer' nmap <F2> :WMToggle<cr> "-------------------------------------------------------------------------------- " NERDTree "-------------------------------------------------------------------------------- let NERDTreeChDirMode=2 let NERDTreeShowHidden=1 let NERDTreeKeepTreeInNewTab=1 let g:NERDTree_title='NERD Tree' "let g:winManagerWindowLayout='NERDTree|TagList,BufExplorer' "let g:winManagerWindowLayout='NERDTree|TagList' "function! NERDTree_Start() " exec 'NERDTree' "endfunction "function! NERDTree_IsValid() " return 1 "endfunction "-------------------------------------------------------------------------------- " minibufexploer "-------------------------------------------------------------------------------- let g:miniBufExplMapCTabSwitchBufs = 1 let g:miniBufExplMapWindowNavVim = 1 "C-w,h j k l 向"左,下,上,右"切换窗口. "let g:miniBufExplMapWindowNavArrows = 1 "使用箭头 "-------------------------------------------------------------------------------- " Gerp "-------------------------------------------------------------------------------- nnoremap <silent> <F4> :Grep<CR> " /<FEAT_QUICKFIX/> 全词匹配 "-------------------------------------------------------------------------------- " 自动补全 "-------------------------------------------------------------------------------- filetype plugin indent on "文件类型检测 set completeopt=longest,menu "关掉智能补全预览窗口 "-------------------------------------------------------------------------------- " netrw 文件浏览器 :e <PATH> "-------------------------------------------------------------------------------- let g:netrw_winsize = 30 " 浏览器宽度 "-------------------------------------------------------------------------------- " 代码折叠 "-------------------------------------------------------------------------------- "set foldmarker={,} "set foldmethod=marker set foldmethod=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 "-------------------------------------------------------------------------------- "注释映射 "-------------------------------------------------------------------------------- let mapleader="," "-------------------------------------------------------------------------------- "在插入模式下移动光标 "-------------------------------------------------------------------------------- inoremap <C-h> <Left> inoremap <C-j> <Down> inoremap <C-k> <Up> inoremap <C-l> <Right> "-------------------------------------------------------------------------------- "q: 打开历史记录 "find ~/work/..Project/ -name "*.h" -o -name "*.cpp" > cscope.files "cscope -bkq -i cscope.files "ctags -R --fields=+lS "-------------------------------------------------------------------------------- "au VimEnter * set buftype=""