1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
| runtime! debian.vim filetype off
set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() "" install Vundle Plugin 'gmarik/Vundle.vim' Plugin 'scrooloose/nerdtree' Plugin 'Xuyuanp/nerdtree-git-plugin' Plugin 'ryanoasis/vim-devicons' Plugin 'vim-syntastic/syntastic' Plugin 'vim-airline/vim-airline' Plugin 'vim-airline/vim-airline-themes' Plugin 'altercation/vim-colors-solarized' Plugin 'majutsushi/tagbar' Plugin 'valloric/youcompleteme' Plugin 'zivyangll/git-blame.vim' Plugin 'haya14busa/incsearch.vim' Plugin 'tpope/vim-fugitive' Plugin 'rhysd/vim-clang-format' Plugin 'instant-markdown/vim-instant-markdown'
call vundle#end() filetype plugin indent on
"" Nerd tree autocmd vimenter * NERDTreeFind wincmd w autocmd vimenter * wincmd w let g:NERDTreeDirArrowExpandable='►' let g:NERDTreeDirArrowCollapsible='▼' let g:NERDTreeWinPos='left' let g:NERDTreeWinSize=40 let g:NERDTreeShowLineNumbers=1 autocmd vimenter * if !argc()|NERDTree|endif autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif ""nnoremap <F10> :NERDTreeToggle<CR> let g:NERDTreeGitStatusIndicatorMapCustom={ \ 'Modified' :'✹', \ 'Staged' :'✚', \ 'Untracked' :'✭', \ 'Renamed' :'➜', \ 'Unmerged' :'═', \ 'Deleted' :'✖', \ 'Dirty' :'✗', \ 'Ignored' :'☒', \ 'Clean' :'✔︎', \ 'Unknown' :'?', \ }
function! IsNERDTreeOpen() return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1) endfunction
function! SyncTree() if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff NERDTreeFind wincmd p endif endfunction
autocmd BufEnter * call SyncTree() function! ToggleNerdTree() set eventignore=BufEnter NERDTreeToggle set eventignore= endfunction ""nmap <C-n> :call ToggleNerdTree()<CR> nmap <F10> :call ToggleNerdTree()<CR>
"" syntastic check execute pathogen#infect() set statusline+=%#warningmsg# set statusline+=%{SyntasticStatuslineFlag()} set statusline+=%{FugitiveStatusline()} set statusline+=%*
"" vim airline let g:airline#extensions#tabline#enabled=1 let g:syntastic_always_populate_loc_list=1 let g:syntastic_auto_loc_list=1 let g:syntastic_check_on_open=1 let g:syntastic_check_on_wq=0
"" vim-colors-solarized syntax enable colorscheme solarized ""colorscheme industry let g:solarized_termcolors=256 call togglebg#map("<F5>") set background=dark
"" tagbar let g:tagbar_ctags_bin='/usr/bin/ctags' let g:tagbar_sort=0 let g:tagbar_width=40 nnoremap <F9> :TagbarToggle<CR>
"" youcompleteme let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py' let g:ycm_confirm_extra_conf=1 let g:ycm_auto_trigger=1
nnoremap <leader>yfw <Plug>(YCMFindSymbolInWorkspace) nnoremap <leader>yfd <Plug>(YCMFindSymbolInDocument) nnoremap <leader>jd :YcmCompleter GoToDefinition<CR> nnoremap <leader>jl :YcmCompleter GoToDeclaration<CR> nnoremap <leader>jf :YcmCompleter GoToDefinition<CR> nnoremap <leader>jg :YcmCompleter GoToDefinitionElseDeclaration<CR> let g:ycm_key_invoke_completion='<c-space>' ""set completeopt=menu,menuone set completeopt=menu set completeopt-=preview let g:ycm_add_preview_to_completeopt=0 let g:ycm_autoclose_preview_window_after_insertion=0 let g:ycm_autoclose_preview_window_after_completion=0 ""autocmd CursorMovedI * if pumvisible() == 0|pclose|endif ""autocmd InsertLeave * if pumvisible() == 0|pclose|endif let g:ycm_filetype_whitelist={ \ "c":1, \ "cc":1, \ "cpp":1, \ "h":1, \ "hpp":1, \ "objc":1, \ "sh":1, \ "zsh":1, \ "zimbu":1, \ } let g:ycm_semantic_triggers = { \ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'], \ 'cs,lua,javascript': ['re!\w{2}'], \ } "" git blame nnoremap <Leader>\ :<C-u>call gitblame#echo()<CR>
"" clang format ""autocmd FileType c ClangFormatAutoEnable ""autocmd FileType h ClangFormatAutoEnable ""autocmd FileType cu ClangFormatAutoEnable ""autocmd FileType cpp ClangFormatAutoEnable ""autocmd FileType hpp ClangFormatAutoEnable let g:clang_format#command = 'clang-format' nmap <F4> :ClangFormat<cr> let g:clang_format#detect_style_file = 1
let g:clang_format#style_options = { \ "BasedOnStyle" : "Google", \ "ColumnLimit" : 110, \ "IndentWidth" : 4 \}
"" instant markdown
set number set showmatch set visualbell set hlsearch set smartcase set gdefault set ignorecase set incsearch set autoindent set cindent set expandtab set shiftwidth=4 set smartindent set smarttab set softtabstop=4 set tabstop=4 set ruler set undolevels=1000 set backspace=indent,eol,start set lazyredraw set scrolloff=1 set display+=lastline set relativenumber set mouse=a set title set autoread set confirm set history=1000 set showcmd set laststatus=2 set nocompatible set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 set termencoding=utf-8 set encoding=utf-8 set modifiable set fileencodings=ucs-bom,utf-8,cp936,latin1 set fileencoding=utf-8 ""set binary set noeol set clipboard+=unnamed set magic set confirm set completeopt=longest,menu set noerrorbells visualbell t_vb= autocmd GUIEnter * set visualbell t_vb= set t_RV=
if has("cscope") && filereadable("/usr/bin/cscope") set csprg=/usr/bin/cscope set csto=0 set cst set nocsverb if filereadable("cscope.out") cs add $PWD/cscope.out elseif $CSCOPE_DB != "" cs add $CSCOPE_DB endif set csverb endif
nnoremap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> nnoremap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR> nnoremap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR> nnoremap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> nnoremap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR> nnoremap <C-\>f :cs find f <C-R>=expand("<cword>")<CR><CR> nnoremap <C-\>i :cs find i <C-R>=expand("<cword>")<CR><CR> nnoremap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR> nnoremap <F12> gg=G
nnoremap <F2> :g/^\s*$/d<CR>
au GUIEnter * simalt ~x
"""""新文件标题"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" autocmd BufNewFile *.py,*.cpp,*.[ch],*.sh,*.java exec ":call SetTitle() autocmd BufNewFile * exec ":call SetTitle()"
""定义函数SetTitle,自动插入文件头 func SetTitle() if &filetype == 'sh' call setline(1,"\#########################################################################") call append(line("."), "\# File Name: ".expand("%")) call append(line(".")+1, "\# Created Time: ".strftime("%c")) call append(line(".")+2, "\#########################################################################") call append(line(".")+3, "\#!/bin/bash") call append(line(".")+4, "") elseif &filetype == 'python' call setline(1,"\#########################################################################") call append(line("."), "\#-*- coding:utf-8 -*-") call append(line(".")+1, "\#!/usr/bin/env python") call append(line(".")+2, "\# File Name: ".expand("%")) call append(line(".")+3, "\# Created Time: ".strftime("%c")) call append(line(".")+4, "\#########################################################################") call append(line(".")+5, "") elseif expand("%:e")== 'h' call setline(1, "/*************************************************************************") call append(line("."), " > File Name: ".expand("%")) call append(line(".")+1, " > Created Time: ".strftime("%c")) call append(line(".")+2, " ************************************************************************/") call append(line(".")+3, "") elseif &filetype == 'cpp' call setline(1, "/*************************************************************************") call append(line("."), " > File Name: ".expand("%")) call append(line(".")+1, " > Created Time: ".strftime("%c")) call append(line(".")+2, " ************************************************************************/") call append(line(".")+3, "") call append(line(".")+4, "#include <iostream>") call append(line(".")+5, "") elseif &filetype == 'c' call setline(1, "/*************************************************************************") call append(line("."), " > File Name: ".expand("%")) call append(line(".")+1, " > Created Time: ".strftime("%c")) call append(line(".")+2, " ************************************************************************/") call append(line(".")+3, "") call append(line(".")+4, "#include <stdio.h>") call append(line(".")+5, "") elseif expand("%:e")== 'md' call setline(1, "```") call append(line("."), "File Name: ".expand("%")) call append(line(".")+1, "Created Time: ".strftime("%c")) call append(line(".")+2, "```") call append(line(".")+3, "") else call setline(1, "/*************************************************************************") call append(line("."), " > File Name: ".expand("%")) call append(line(".")+1, " > Created Time: ".strftime("%c")) call append(line(".")+2, " ************************************************************************/") call append(line(".")+3, "") endif autocmd BufNewFile * normal G endfunc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:inoremap ( ()<ESC>i :inoremap ) <c-r>=ClosePair(')')<CR> :inoremap { {<CR>}<ESC>O :inoremap } <c-r>=ClosePair('}')<CR> :inoremap [ []<ESC>i :inoremap ] <c-r>=ClosePair(']')<CR> :inoremap " " :inoremap ' ''<ESC>i function! ClosePair(char) if getline('.')[col('.') - 1] == a:char return "\<Right>" else return a:char endif endfunction filetype plugin indent on
"highlight Functions autocmd BufNewFile,BufRead * :syntax match cfunctions "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2 autocmd BufNewFile,BufRead * :syntax match cfunctions "\<[a-zA-Z_][a-zA-Z_0-9]*\>\s*("me=e-1 hi cFunctions gui=NONE cterm=bold ctermfg=blue
hi PreCondit ctermfg=161 cterm=bold highlight LineNr ctermfg=darkblue hi MatchParen ctermbg=Yellow guibg=lightblue hi ModeMsg ctermfg=Green
set cursorline hi CursorLine cterm=underline hi SpellBad gui=undercurl ctermbg=52 hi SpellCap guisp=#7070F0 gui=undercurl hi SpellLocal guisp=#70F0F0 gui=undercurl hi SpellRare guisp=#FFFFFF gui=undercurl hi SpellCap ctermbg=17 hi SpellLocal ctermbg=17 hi SpellRare ctermfg=none ctermbg=none cterm=reverse
let vim_markdown_preview_github=1
" Only do this part when compiled with support for autocommands if has("autocmd") augroup redhat autocmd! " In text files, always limit the width of text to 78 characters " autocmd BufRead *.txt set tw=78 " When editing a file, always jump to the last cursor position autocmd BufReadPost * \ if line("'\"") > 0 && line ("'\"") <= line("$") | \ exe "normal! g'\"" | \ endif autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec augroup END endif
"" vimdiff if &diff colorscheme evening endif
""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""" function! CheckChineseMark() if search('。') execute "%s/。/\." endif
if search(',') execute "%s/,/," endif
if search(';') execute "%s/;/;" endif
if search('?') execute "%s/?/?" endif
if search(':') execute "%s/:/\:" endif
if search('‘') execute "%s/‘/\'" endif
if search('’') execute "%s/’/\'" endif
if search('”') execute "%s/”/\"" endif
if search('“') execute "%s/“/\"" endif
if search('《') execute "%s/《/\<" endif
if search('》') execute "%s/》/\>" endif
if search('——') execute "%s/——/-" endif
if search(')') execute "%s/)/\)" endif
if search('(') execute "%s/(/\(" endif
if search('!') execute "%s/!/!" endif
if search('【') execute "%s/【/\[" endif
if search('】') execute "%s/】/\]" endif endfunction nnoremap <C-L> <ESC>:call CheckChineseMark()<ESC>
|