Linux VIM配置

来源:互联网 发布:crm系统 php源码 编辑:程序博客网 时间:2024/06/03 10:29

刚开始用Vim不久,特别喜欢倒腾它,记录下自己的.vimrc文件。只是些简单的配置。如下:


"""""""""""""""""""""""""""""""""""""""" VIM PLUGIN MANAGEMENT CONFIGURATION """"""""""""""""""""""""""""""""""""""""set nocompatible " be iMprovedfiletype off " required! set rtp+=~/.vim/bundle/vundle/call vundle#rc()" let Vundle manage Vundle" required!Bundle 'gmarik/vundle'" My Bundles here: Bundle 'scrooloose/nerdtree'Bundle 'majutsushi/tagbar'Bundle 'Valloric/YouCompleteMe'Bundle 'scrooloose/syntastic'Bundle 'Lokaltog/vim-powerline'Bundle "davidhalter/jedi"Bundle 'nvie/vim-flake8'Bundle 'fholgado/minibufexpl.vim'Plugin 'kien/ctrlp.vim'" original repos on github (Github网站上非vim-scripts仓库的插件,按下面格式填写)"Bundle 'tpope/vim-fugitive'"Bundle 'Lokaltog/vim-easymotion'"Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}"Bundle 'tpope/vim-rails.git'" vim-scripts repos (vim-scripts仓库里的,按下面格式填写)"Bundle 'L9'"Bundle 'FuzzyFinder'" non github repos (非上面两种情况的,按下面格式填写)"Bundle 'git://git.wincent.com/command-t.git'" ...filetype plugin indent on " required! /** vimrc文件配置结束 **/" /** vundle命令 **/" Brief help" :BundleList - list configured bundles" :BundleInstall(!) - install(update) bundles" :BundleSearch(!) foo - search(or refresh cache first) for foo" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles" see :h vundle for more details or wiki for FAQ" NOTE: comments after Bundle command are not allowed.."=============NERDTree============map <F3> :NERDTreeMirror<CR>map <F3> :NERDTreeToggle<CR>let NERDChristmasTree=0let NERDTreeWinSize=30let NERDTreeChDirMode=2let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']let NERDTreeWinPos="left"let NERDTreeShowBookmarks=1"--- Automatically open a NERDTree if no files where specifiedautocmd vimenter * if !argc() | NERDTree | endif"--- 只是nerdtree窗口时关闭vimautocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif"--- s/v 分屏打开文件  let g:NERDTreeMapOpenSplit = 's'  let g:NERDTreeMapOpenVSplit = 'v'"o 打开关闭文件或者目录"t 在标签页中打开"T 在后台标签页中打开"! 执行此文件"p 到上层目录"P 到根目录"K 到第一个节点"J 到最后一个节点"u 打开上层目录"m 显示文件系统菜单(添加、删除、移动操作)"? 帮助"q 关闭"=============Tagbar============map <F2> :TagbarMirror<CR>map <F2> :TagbarToggle<CR>"let g:tagbar_width=30let g:tagbar_autofocus=1"=============CTags============"=============PowerLine============"set laststatus=2"==============minibufexpl==========="<Tab>  切换buffer"左右方向键  切换buffer"bn   切到后一个"bp   切到前一个"bd   关闭当前bufferlet g:miniBufExplMapWindowNavVim = 1let g:miniBufExplMapWindowNavArrows = 1let g:miniBufExplMapCTabSwitchBufs = 1let g:miniBufExplModSelTarget = 1"--- 不要在不可编辑内容的窗口(如TagList窗口)中打开选中的bufferlet g:miniBufExplModSelTarget = 1 "用法:"<Tab>  移到上一个buffer"<Shift-Tab> 移到下一个buffer"<Enter>  打开光标所在的buffer"=============syntastic============"--- github configurationset statusline+=%#warningmsg#set statusline+=%{SyntasticStatuslineFlag()}set statusline+=%*let g:syntastic_always_populate_loc_list = 1let g:syntastic_auto_loc_list = 1let g:syntastic_check_on_open = 1let g:syntastic_check_on_wq = 0let g:syntastic_error_symbol='>>'  let g:syntastic_warning_symbol='>*'  let g:syntastic_enable_highlighting=1  let g:syntastic_loc_list_height = 5"--- 修改高亮的背景颜色,适应主题  highlight SyntasticErrorSign guifg=white guibg=black"--- 使用pyflakes,速度比pylint快"--- python_checkers pyflakes/pep8/jshint ---let g:syntastic_python_checkers=['flake8'] "let g:syntastic_python_checkers = ['pylint']" configure syntastic syntax checking to check on open as well as save" let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"]" set statusline+=%#warningmsg#" set statusline+=%{SyntasticStatuslineFlag()}" set statusline+=%*"--- flake8"Auto-check file for errors on write: "let g:PyFlakeOnWrite = 1 "List of checkers used: "let g:PyFlakeCheckers = 'pep8,mccabe,pyflakes' "Default maximum complexity for mccabe: "let g:PyFlakeDefaultComplexity=10 "List of disabled pep8 warnings and errors: "let g:PyFlakeDisabledMessages = 'E501' "Default height of quickfix window: "let g:PyFlakeCWindow = 6 "Whether to place signs or not: "let g:PyFlakeSigns = 1 "Maximum line length for PyFlakeAuto command "let g:PyFlakeMaxLineLength = 100 ""Visual-mode key command for PyFlakeAuto "let g:PyFlakeRangeCommand = 'Q' "--- flake8的快速修复 PyFlakeAuto功能 "map <F6> :PyFlakeAuto<CR>"=============YouCompleteMe============let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py""--- 不显示每次加载配置文件的提示let g:ycm_confirm_extra_conf = 0let g:ycm_auto_trigger = 1let g:ycm_error_symbol = '>>'let g:ycm_warning_symbol = '>*'let g:ycm_autoclose_preview_window_after_completion = 1 let g:ycm_autoclose_preview_window_after_insertion = 1"--- 跳转到声明nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR>"--- 跳转到定义nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>"--- 跳转到两者的合体nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR>"--- 命令 :YcmDiags 可以打开location-list查看警告和错误信息nnoremap <F4> :YcmDiags<CR>inoremap <c-o> <c-x><c-o>"--- 在注释输入中也能补全let g:ycm_complete_in_comments = 1"--- 在字符串输入中也能补全let g:ycm_complete_in_strings = 1"--- 注释和字符串中的文字也会被收入补全let g:ycm_collect_identifiers_from_comments_and_strings = 0"--- 让Vim的补全菜单行为与一般IDE一致set completeopt=longest,menu"--- 离开插入模式后自动关闭预览窗口autocmd InsertLeave * if pumvisible() == 0|pclose|endif"回车即选中当前项"inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>""--- 从第2个键入字符就开始罗列匹配项let g:ycm_min_num_of_chars_for_completion=1"--- 禁止缓存匹配项,每次都重新生成匹配项" let g:ycm_cache_omnifunc=0"--- 语法关键字补全let g:ycm_seed_identifiers_with_syntax=1"--- 设置在下面几种格式的文件上屏蔽ycmlet g:ycm_filetype_blacklist = {\ 'tagbar' : 1,\ 'nerdtree' : 1,\}"=============Jedi============" Jedi for Pythonset autochdir"=============Vim UI============set encoding=utf-8set showcmd "--- 共享剪贴板  "set clipboard+=unnamed"--- 突出显示当前行"set cursorline"set cursorcolumn"--- 语法高亮"set syntax=on"--- 自动缩进set autoindentset cindent"--- Tab键的宽度set tabstop=4"--- 统一缩进为4set softtabstop=4set shiftwidth=4"--- 显示行号set number"--- 搜索忽略大小写set ignorecase"--- 搜索逐字符高亮set hlsearchset incsearch"--- 总是显示状态行set laststatus=2"--- 命令行(在状态行下)的高度,默认为1,这里是2set cmdheight=2"--- 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)"set mouse=a"set selection=exclusive"set selectmode=mouse,key"--- 光标移动到buffer的顶部和底部时保持3行距离set scrolloff=3let python_highlight_all=1"--- 设置背景syntax enableset t_Co=256"colorscheme desert256"set background=darkcolorscheme desert"colorscheme solarized"set background=dark"colorscheme molokai"let g:molokai_original=1"set background=dark"---remap nnoremap <C-h> <C-w>hnnoremap <C-j> <C-w>jnnoremap <C-k> <C-w>knnoremap <C-l> <C-w>l"--- 选中状态下 Ctrl+Shift+c 复制"vmap <C-S-c> "+y"vmap <C-S-v> "+p"""""""""""""""""""""""Quickly Run""""""""""""""""""""""map <F5> :call CompileRunGcc()<CR>func! CompileRunGcc()    exec "w"    if &filetype == 'c'        exec "!g++ % -o %<"        exec "!time ./%<"    elseif &filetype == 'cpp'        exec "!g++ % -o %<"        exec "!time ./%<"    elseif &filetype == 'java'        exec "!javac %"        exec "!time java %<"    elseif &filetype == 'sh'        :!time bash %    elseif &filetype == 'python'        exec "!time python2.7 %"    elseif &filetype == 'html'        exec "!firefox % &"    elseif &filetype == 'go'        exec "!time go run %"    elseif &filetype == 'mkd'        exec "!~/.vim/markdown.pl % > %.html &"        exec "!firefox %.html &"    endifendfunc" Enable foldingset foldmethod=indentset foldlevel=99"Enable folding with the spacebarnnoremap <space> za
0 0