转载自:飞在天空的鱼 - 博客频道http://blog.csdn.net/zhengzhoudaxue2/article/details/45247733?locationNum=15&fps=1

[cpp] view plaincopy
  1. " All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by
  2. " the call to :runtime you can find below.  If you wish to change any of those
  3. " settings, you should do it in this file (/etc/vim/vimrc), since debian.vim
  4. " will be overwritten everytime an upgrade of the vim packages is performed.
  5. " It is recommended to make changes after sourcing debian.vim since it alters
  6. " the value of the 'compatible' option.
  7. " This line should not be removed as it ensures that various options are
  8. " properly set to work with the Vim-related packages available in Debian.
  9. runtime! debian.vim
  10. " Uncomment the next line to make Vim more Vi-compatible
  11. " NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
  12. " options, so any other options should be set AFTER setting 'compatible'.
  13. "set compatible
  14. " Vim5 and later versions support syntax highlighting. Uncommenting the next
  15. " line enables syntax highlighting by default.
  16. if has("syntax")
  17. syntax on
  18. endif
  19. " If using a dark background within the editing area and syntax highlighting
  20. " turn on this option as well
  21. "set background=dark
  22. " Uncomment the following to have Vim jump to the last position when
  23. " reopening a file
  24. "if has("autocmd")
  25. "  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
  26. "endif
  27. " Uncomment the following to have Vim load indentation rules and plugins
  28. " according to the detected filetype.
  29. "if has("autocmd")
  30. "  filetype plugin indent on
  31. "endif
  32. " The following are commented out as they cause vim to behave a lot
  33. " differently from regular Vi. They are highly recommended though.
  34. "set showcmd        " Show (partial) command in status line.
  35. "set showmatch      " Show matching brackets.
  36. "set ignorecase     " Do case insensitive matching
  37. "set smartcase      " Do smart case matching
  38. "set incsearch      " Incremental search
  39. "set autowrite      " Automatically save before commands like :next and :make
  40. "set hidden     " Hide buffers when they are abandoned
  41. "set mouse=a        " Enable mouse usage (all modes)
  42. " Source a global configuration file if available
  43. if filereadable("/etc/vim/vimrc.local")
  44. source /etc/vim/vimrc.local
  45. endif
  46. " =============================================================================
  47. "        << 判断操作系统是 Windows 还是 Linux 和判断是终端还是 Gvim >>
  48. " =============================================================================
  49. " -----------------------------------------------------------------------------
  50. "  < 判断操作系统是否是 Windows 还是 Linux >
  51. " -----------------------------------------------------------------------------
  52. let g:iswindows = 0
  53. let g:islinux = 0
  54. if(has("win32") || has("win64") || has("win95") || has("win16"))
  55. let g:iswindows = 1
  56. else
  57. let g:islinux = 1
  58. endif
  59. " -----------------------------------------------------------------------------
  60. "  < 判断是终端还是 Gvim >
  61. " -----------------------------------------------------------------------------
  62. if has("gui_running")
  63. let g:isGUI = 1
  64. else
  65. let g:isGUI = 0
  66. endif
  67. " =============================================================================
  68. "                          << 以下为软件默认配置 >>
  69. " =============================================================================
  70. " -----------------------------------------------------------------------------
  71. "  < Windows Gvim 默认配置> 做了一点修改
  72. " -----------------------------------------------------------------------------
  73. if (g:iswindows && g:isGUI)
  74. source $VIMRUNTIME/vimrc_example.vim
  75. source $VIMRUNTIME/mswin.vim
  76. behave mswin
  77. set diffexpr=MyDiff()
  78. function MyDiff()
  79. let opt = '-a --binary '
  80. if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  81. if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  82. let arg1 = v:fname_in
  83. if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  84. let arg2 = v:fname_new
  85. if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  86. let arg3 = v:fname_out
  87. if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  88. let eq = ''
  89. if $VIMRUNTIME =~ ' '
  90. if &sh =~ '\<cmd'
  91. let cmd = '""' . $VIMRUNTIME . '\diff"'
  92. let eq = '"'
  93. else
  94. let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
  95. endif
  96. else
  97. let cmd = $VIMRUNTIME . '\diff'
  98. endif
  99. silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
  100. endfunction
  101. endif
  102. " -----------------------------------------------------------------------------
  103. "  < Linux Gvim/Vim 默认配置> 做了一点修改
  104. " -----------------------------------------------------------------------------
  105. if g:islinux
  106. set hlsearch        "高亮搜索
  107. set incsearch       "在输入要搜索的文字时,实时匹配
  108. " Uncomment the following to have Vim jump to the last position when
  109. " reopening a file
  110. if has("autocmd")
  111. au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
  112. endif
  113. if g:isGUI
  114. " Source a global configuration file if available
  115. if filereadable("/etc/vim/gvimrc.local")
  116. source /etc/vim/gvimrc.local
  117. endif
  118. else
  119. " This line should not be removed as it ensures that various options are
  120. " properly set to work with the Vim-related packages available in Debian.
  121. runtime! debian.vim
  122. " Vim5 and later versions support syntax highlighting. Uncommenting the next
  123. " line enables syntax highlighting by default.
  124. if has("syntax")
  125. syntax on
  126. endif
  127. set mouse=a                    " 在任何模式下启用鼠标
  128. "set t_Co=256                   " 在终端启用256色
  129. set backspace=2                " 设置退格键可用
  130. " Source a global configuration file if available
  131. if filereadable("/etc/vim/vimrc.local")
  132. source /etc/vim/vimrc.local
  133. endif
  134. endif
  135. endif
  136. " =============================================================================
  137. "                          << 以下为用户自定义配置 >>
  138. " =============================================================================
  139. " -----------------------------------------------------------------------------
  140. "  < Vundle 插件管理工具配置 >
  141. " -----------------------------------------------------------------------------
  142. " 用于更方便的管理vim插件,具体用法参考 :h vundle 帮助
  143. " Vundle工具安装方法为在终端输入如下命令
  144. " git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
  145. " 如果想在 windows 安装就必需先安装 "git for window",可查阅网上资料
  146. set nocompatible                                      "禁用 Vi 兼容模式
  147. filetype off                                          "禁用文件类型侦测
  148. if g:islinux
  149. set rtp+=/home/hisome/.vim/bundle/vundle/
  150. call vundle#rc()
  151. else
  152. set rtp+=$VIM/vimfiles/bundle/vundle/
  153. call vundle#rc('$VIM/vimfiles/bundle/')
  154. endif
  155. " 使用Vundle来管理插件,这个必须要有。
  156. Bundle 'gmarik/vundle'
  157. " 以下为要安装或更新的插件,不同仓库都有(具体书写规范请参考帮助)
  158. Bundle 'a.vim'
  159. Bundle 'Align'
  160. Bundle 'jiangmiao/auto-pairs'
  161. Bundle 'bufexplorer.zip'
  162. Bundle 'ccvext.vim'
  163. Bundle 'cSyntaxAfter'
  164. Bundle 'ctrlpvim/ctrlp.vim'
  165. Bundle 'mattn/emmet-vim'
  166. Bundle 'Yggdroot/indentLine'
  167. Bundle 'vim-javacompleteex'
  168. Bundle 'Mark--Karkat'
  169. Bundle 'Shougo/neocomplcache.vim'
  170. Bundle 'scrooloose/nerdcommenter'
  171. Bundle 'scrooloose/nerdtree'
  172. Bundle 'OmniCppComplete'
  173. Bundle 'Lokaltog/vim-powerline'
  174. Bundle 'repeat.vim'
  175. Bundle 'msanders/snipmate.vim'
  176. Bundle 'wesleyche/SrcExpl'
  177. Bundle 'std_c.zip'
  178. Bundle 'tpope/vim-surround'
  179. Bundle 'scrooloose/syntastic'
  180. Bundle 'majutsushi/tagbar'
  181. Bundle 'taglist.vim'
  182. Bundle 'TxtBrowser'
  183. Bundle 'ZoomWin'
  184. Bundle 'WinManager'
  185. Bundle 'DoxygenToolkit.vim'
  186. " -----------------------------------------------------------------------------
  187. "  < 编码配置 >
  188. " -----------------------------------------------------------------------------
  189. " 注:使用utf-8格式后,软件与程序源码、文件路径不能有中文,否则报错
  190. set encoding=utf-8                                   "设置gvim内部编码,默认不更改
  191. set fileencoding=utf-8                                "设置当前文件编码,可以更改,如:gbk(同cp936)
  192. set fileencodings=ucs-bom,utf-8,gbk,cp936,latin-1     "设置支持打开的文件的编码
  193. " 文件格式,默认 ffs=dos,unix
  194. set fileformat=unix                                   "设置新(当前)文件的<EOL>格式,可以更改,如:dos(windows系统常用)
  195. set fileformats=unix,dos,mac                          "给出文件的<EOL>格式类型
  196. if (g:iswindows && g:isGUI)
  197. "解决菜单乱码
  198. source $VIMRUNTIME/delmenu.vim
  199. source $VIMRUNTIME/menu.vim
  200. "解决consle输出乱码
  201. language messages zh_CN.utf-8
  202. endif
  203. " -----------------------------------------------------------------------------
  204. "  < 编写文件时的配置 >
  205. " -----------------------------------------------------------------------------
  206. filetype on                                           "启用文件类型侦测
  207. filetype plugin on                                    "针对不同的文件类型加载对应的插件
  208. filetype plugin indent on                             "启用缩进
  209. set smartindent                                       "启用智能对齐方式
  210. set expandtab                                         "将Tab键转换为空格
  211. set tabstop=4                                         "设置Tab键的宽度,可以更改,如:宽度为2
  212. set shiftwidth=4                                      "换行时自动缩进宽度,可更改(宽度同tabstop)
  213. set smarttab                                          "指定按一次backspace就删除shiftwidth宽度
  214. "set foldenable                                        "启用折叠
  215. "set foldmethod=indent                                 "indent 折叠方式
  216. "set foldcolumn=2
  217. "set foldlevel=3
  218. " set foldmethod=marker                                "marker 折叠方式
  219. "AutoCommand
  220. "新建.c,.h,.sh,.java文件,自动插入文件头
  221. autocmd BufNewFile *.[ch],*.sh,*.java exec ":call SetTitle()"
  222. "新建文件后,自动定位到文件末尾
  223. autocmd BufNewFile * normal G
  224. " 常规模式下用空格键来开关光标行所在折叠(注:zR 展开所有折叠,zM 关闭所有折叠)
  225. nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
  226. " 当文件在外部被修改,自动更新该文件
  227. set autoread
  228. " 常规模式下输入 cS 清除行尾空格
  229. nmap cS :%s/\s\+$//g<CR>:noh<CR>
  230. " 常规模式下输入 cM 清除行尾 ^M 符号
  231. nmap cM :%s/\r$//g<CR>:noh<CR>
  232. set ignorecase                                        "搜索模式里忽略大小写
  233. set smartcase                                         "如果搜索模式包含大写字符,不使用 'ignorecase' 选项,只有在输入搜索模式并且打开 'ignorecase' 选项时才会使用
  234. " set noincsearch                                       "在输入要搜索的文字时,取消实时匹配
  235. " Ctrl + K 插入模式下光标向上移动
  236. imap <c-k> <Up>
  237. " Ctrl + J 插入模式下光标向下移动
  238. imap <c-j> <Down>
  239. " Ctrl + H 插入模式下光标向左移动
  240. imap <c-h> <Left>
  241. " Ctrl + L 插入模式下光标向右移动
  242. imap <c-l> <Right>
  243. " 启用每行超过120列的字符提示(字体变蓝并加下划线),不启用就注释掉
  244. "au BufWinEnter * let w:m2=matchadd('Underlined', '\%>' . 120 . 'v.\+', -1)
  245. " -----------------------------------------------------------------------------
  246. "  < 界面配置 >
  247. " -----------------------------------------------------------------------------
  248. set number                                            "显示行号
  249. set laststatus=2                                      "启用状态栏信息
  250. set cmdheight=2                                       "设置命令行的高度为2,默认为1
  251. set cursorline                                        "突出显示当前行
  252. " set guifont=YaHei_Consolas_Hybrid:h10                 "设置字体:字号(字体名称空格用下划线代替)
  253. set nowrap                                            "设置不自动换行
  254. set shortmess=atI                                     "去掉欢迎界面
  255. " 设置 gVim 窗口初始位置及大小
  256. if g:isGUI
  257. " au GUIEnter * simalt ~x                           "窗口启动时自动最大化
  258. winpos 100 10                                     "指定窗口出现的位置,坐标原点在屏幕左上角
  259. set lines=38 columns=120                          "指定窗口大小,lines为高度,columns为宽度
  260. endif
  261. " 设置代码配色方案
  262. set t_Co=256
  263. set background=dark
  264. colorscheme molokai
  265. "if g:isGUI
  266. "   colorscheme Tomorrow-Night-Eighties               "Gvim配色方案
  267. "else
  268. "    colorscheme Tomorrow-Night-Eighties               "终端配色方案
  269. "endif
  270. " 显示/隐藏菜单栏、工具栏、滚动条,可用 Ctrl + F11 切换
  271. if g:isGUI
  272. set guioptions-=m
  273. set guioptions-=T
  274. set guioptions-=r
  275. set guioptions-=L
  276. nmap <silent> <c-F11> :if &guioptions =~# 'm' <Bar>
  277. \set guioptions-=m <Bar>
  278. \set guioptions-=T <Bar>
  279. \set guioptions-=r <Bar>
  280. \set guioptions-=L <Bar>
  281. \else <Bar>
  282. \set guioptions+=m <Bar>
  283. \set guioptions+=T <Bar>
  284. \set guioptions+=r <Bar>
  285. \set guioptions+=L <Bar>
  286. \endif<CR>
  287. endif
  288. " -----------------------------------------------------------------------------
  289. "  < 编译、连接、运行配置 (目前只配置了C、C++、Java语言)>
  290. " -----------------------------------------------------------------------------
  291. " F9 一键保存、编译、连接存并运行
  292. nmap <F9> :call Run()<CR>
  293. imap <F9> <ESC>:call Run()<CR>
  294. " Ctrl + F9 一键保存并编译
  295. nmap <c-F9> :call Compile()<CR>
  296. imap <c-F9> <ESC>:call Compile()<CR>
  297. " Ctrl + F10 一键保存并连接
  298. nmap <c-F10> :call Link()<CR>
  299. imap <c-F10> <ESC>:call Link()<CR>
  300. let s:LastShellReturn_C = 0
  301. let s:LastShellReturn_L = 0
  302. let s:ShowWarning = 1
  303. let s:Obj_Extension = '.o'
  304. let s:Exe_Extension = '.exe'
  305. let s:Class_Extension = '.class'
  306. let s:Sou_Error = 0
  307. let s:windows_CFlags = 'gcc\ -fexec-charset=gbk\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'
  308. let s:linux_CFlags = 'gcc\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'
  309. let s:windows_CPPFlags = 'g++\ -fexec-charset=gbk\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'
  310. let s:linux_CPPFlags = 'g++\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'
  311. let s:JavaFlags = 'javac\ %'
  312. func! Compile()
  313. exe ":ccl"
  314. exe ":update"
  315. let s:Sou_Error = 0
  316. let s:LastShellReturn_C = 0
  317. let Sou = expand("%:p")
  318. let v:statusmsg = ''
  319. if expand("%:e") == "c" || expand("%:e") == "cpp" || expand("%:e") == "cxx"
  320. let Obj = expand("%:p:r").s:Obj_Extension
  321. let Obj_Name = expand("%:p:t:r").s:Obj_Extension
  322. if !filereadable(Obj) || (filereadable(Obj) && (getftime(Obj) < getftime(Sou)))
  323. redraw!
  324. if expand("%:e") == "c"
  325. if g:iswindows
  326. exe ":setlocal makeprg=".s:windows_CFlags
  327. else
  328. exe ":setlocal makeprg=".s:linux_CFlags
  329. endif
  330. echohl WarningMsg | echo " compiling..."
  331. silent make
  332. elseif expand("%:e") == "cpp" || expand("%:e") == "cxx"
  333. if g:iswindows
  334. exe ":setlocal makeprg=".s:windows_CPPFlags
  335. else
  336. exe ":setlocal makeprg=".s:linux_CPPFlags
  337. endif
  338. echohl WarningMsg | echo " compiling..."
  339. silent make
  340. endif
  341. redraw!
  342. if v:shell_error != 0
  343. let s:LastShellReturn_C = v:shell_error
  344. endif
  345. if g:iswindows
  346. if s:LastShellReturn_C != 0
  347. exe ":bo cope"
  348. echohl WarningMsg | echo " compilation failed"
  349. else
  350. if s:ShowWarning
  351. exe ":bo cw"
  352. endif
  353. echohl WarningMsg | echo " compilation successful"
  354. endif
  355. else
  356. if empty(v:statusmsg)
  357. echohl WarningMsg | echo " compilation successful"
  358. else
  359. exe ":bo cope"
  360. endif
  361. endif
  362. else
  363. echohl WarningMsg | echo ""Obj_Name"is up to date"
  364. endif
  365. elseif expand("%:e") == "java"
  366. let class = expand("%:p:r").s:Class_Extension
  367. let class_Name = expand("%:p:t:r").s:Class_Extension
  368. if !filereadable(class) || (filereadable(class) && (getftime(class) < getftime(Sou)))
  369. redraw!
  370. exe ":setlocal makeprg=".s:JavaFlags
  371. echohl WarningMsg | echo " compiling..."
  372. silent make
  373. redraw!
  374. if v:shell_error != 0
  375. let s:LastShellReturn_C = v:shell_error
  376. endif
  377. if g:iswindows
  378. if s:LastShellReturn_C != 0
  379. exe ":bo cope"
  380. echohl WarningMsg | echo " compilation failed"
  381. else
  382. if s:ShowWarning
  383. exe ":bo cw"
  384. endif
  385. echohl WarningMsg | echo " compilation successful"
  386. endif
  387. else
  388. if empty(v:statusmsg)
  389. echohl WarningMsg | echo " compilation successful"
  390. else
  391. exe ":bo cope"
  392. endif
  393. endif
  394. else
  395. echohl WarningMsg | echo ""class_Name"is up to date"
  396. endif
  397. else
  398. let s:Sou_Error = 1
  399. echohl WarningMsg | echo " please choose the correct source file"
  400. endif
  401. exe ":setlocal makeprg=make"
  402. endfunc
  403. func! Link()
  404. call Compile()
  405. if s:Sou_Error || s:LastShellReturn_C != 0
  406. return
  407. endif
  408. if expand("%:e") == "c" || expand("%:e") == "cpp" || expand("%:e") == "cxx"
  409. let s:LastShellReturn_L = 0
  410. let Sou = expand("%:p")
  411. let Obj = expand("%:p:r").s:Obj_Extension
  412. if g:iswindows
  413. let Exe = expand("%:p:r").s:Exe_Extension
  414. let Exe_Name = expand("%:p:t:r").s:Exe_Extension
  415. else
  416. let Exe = expand("%:p:r")
  417. let Exe_Name = expand("%:p:t:r")
  418. endif
  419. let v:statusmsg = ''
  420. if filereadable(Obj) && (getftime(Obj) >= getftime(Sou))
  421. redraw!
  422. if !executable(Exe) || (executable(Exe) && getftime(Exe) < getftime(Obj))
  423. if expand("%:e") == "c"
  424. setlocal makeprg=gcc\ -o\ %<\ %<.o
  425. echohl WarningMsg | echo " linking..."
  426. silent make
  427. elseif expand("%:e") == "cpp" || expand("%:e") == "cxx"
  428. setlocal makeprg=g++\ -o\ %<\ %<.o
  429. echohl WarningMsg | echo " linking..."
  430. silent make
  431. endif
  432. redraw!
  433. if v:shell_error != 0
  434. let s:LastShellReturn_L = v:shell_error
  435. endif
  436. if g:iswindows
  437. if s:LastShellReturn_L != 0
  438. exe ":bo cope"
  439. echohl WarningMsg | echo " linking failed"
  440. else
  441. if s:ShowWarning
  442. exe ":bo cw"
  443. endif
  444. echohl WarningMsg | echo " linking successful"
  445. endif
  446. else
  447. if empty(v:statusmsg)
  448. echohl WarningMsg | echo " linking successful"
  449. else
  450. exe ":bo cope"
  451. endif
  452. endif
  453. else
  454. echohl WarningMsg | echo ""Exe_Name"is up to date"
  455. endif
  456. endif
  457. setlocal makeprg=make
  458. elseif expand("%:e") == "java"
  459. return
  460. endif
  461. endfunc
  462. func! Run()
  463. let s:ShowWarning = 0
  464. call Link()
  465. let s:ShowWarning = 1
  466. if s:Sou_Error || s:LastShellReturn_C != 0 || s:LastShellReturn_L != 0
  467. return
  468. endif
  469. let Sou = expand("%:p")
  470. if expand("%:e") == "c" || expand("%:e") == "cpp" || expand("%:e") == "cxx"
  471. let Obj = expand("%:p:r").s:Obj_Extension
  472. if g:iswindows
  473. let Exe = expand("%:p:r").s:Exe_Extension
  474. else
  475. let Exe = expand("%:p:r")
  476. endif
  477. if executable(Exe) && getftime(Exe) >= getftime(Obj) && getftime(Obj) >= getftime(Sou)
  478. redraw!
  479. echohl WarningMsg | echo " running..."
  480. if g:iswindows
  481. exe ":!%<.exe"
  482. else
  483. if g:isGUI
  484. exe ":!gnome-terminal -x bash -c './%<; echo; echo 请按 Enter 键继续; read'"
  485. else
  486. exe ":!clear; ./%<"
  487. endif
  488. endif
  489. redraw!
  490. echohl WarningMsg | echo " running finish"
  491. endif
  492. elseif expand("%:e") == "java"
  493. let class = expand("%:p:r").s:Class_Extension
  494. if getftime(class) >= getftime(Sou)
  495. redraw!
  496. echohl WarningMsg | echo " running..."
  497. if g:iswindows
  498. exe ":!java %<"
  499. else
  500. if g:isGUI
  501. exe ":!gnome-terminal -x bash -c 'java %<; echo; echo 请按 Enter 键继续; read'"
  502. else
  503. exe ":!clear; java %<"
  504. endif
  505. endif
  506. redraw!
  507. echohl WarningMsg | echo " running finish"
  508. endif
  509. endif
  510. endfunc
  511. " -----------------------------------------------------------------------------
  512. "  < 其它配置 >
  513. " -----------------------------------------------------------------------------
  514. set writebackup                             "保存文件前建立备份,保存成功后删除该备份
  515. set nobackup                                "设置无备份文件
  516. " set noswapfile                              "设置无临时文件
  517. " set vb t_vb=                                "关闭提示音
  518. " -----------------------------------------------------------------------------
  519. "定义函数SetTitle,自动插入文件头
  520. " -----------------------------------------------------------------------------
  521. func SetTitle()
  522. "如果文件类型为.sh文件
  523. if &filetype == 'sh'
  524. call setline(1, "\#########################################################################")
  525. call append(line("."), "\# Author: zhangbo")
  526. call append(line(".")+1, "\# Created Time: ".strftime("%c"))
  527. call append(line(".")+2, "\# File Name: ".expand("%"))
  528. call append(line(".")+3, "\# Description: ")
  529. call append(line(".")+4, "\#########################################################################")
  530. call append(line(".")+5, "\#!/bin/bash")
  531. call append(line(".")+6, "")
  532. else
  533. call setline(1, "/*************************************************************************")
  534. call append(line("."), " Author: zhangbo")
  535. call append(line(".")+1, " Created Time: ".strftime("%c"))
  536. call append(line(".")+2, " File Name: ".expand("%"))
  537. call append(line(".")+3, " Description: ")
  538. call append(line(".")+4, " ************************************************************************/")
  539. call append(line(".")+5, "")
  540. endif
  541. endfunc
  542. " =============================================================================
  543. "                          << 以下为常用插件配置 >>
  544. " =============================================================================
  545. " -----------------------------------------------------------------------------
  546. "  < a.vim 插件配置 >
  547. " -----------------------------------------------------------------------------
  548. " 用于切换C/C++头文件
  549. " :A     ---切换头文件并独占整个窗口
  550. " :AV    ---切换头文件并垂直分割窗口
  551. " :AS    ---切换头文件并水平分割窗口
  552. nnoremap <silent> <F12> : A<CR>
  553. " -----------------------------------------------------------------------------
  554. "  < Align 插件配置 >
  555. " -----------------------------------------------------------------------------
  556. " 一个对齐的插件,用来——排版与对齐代码,功能强大,不过用到的机会不多
  557. " -----------------------------------------------------------------------------
  558. "  < auto-pairs 插件配置 >
  559. " -----------------------------------------------------------------------------
  560. " 用于括号与引号自动补全,不过会与函数原型提示插件echofunc冲突
  561. " 所以我就没有加入echofunc插件
  562. " -----------------------------------------------------------------------------
  563. "  < BufExplorer 插件配置 >
  564. " -----------------------------------------------------------------------------
  565. " 快速轻松的在缓存中切换(相当于另一种多个文件间的切换方式)
  566. " <Leader>be 在当前窗口显示缓存列表并打开选定文件
  567. " <Leader>bs 水平分割窗口显示缓存列表,并在缓存列表窗口中打开选定文件
  568. " <Leader>bv 垂直分割窗口显示缓存列表,并在缓存列表窗口中打开选定文件
  569. " -----------------------------------------------------------------------------
  570. "  < ccvext.vim 插件配置 >
  571. " -----------------------------------------------------------------------------
  572. " 用于对指定文件自动生成tags与cscope文件并连接
  573. " 如果是Windows系统, 则生成的文件在源文件所在盘符根目录的.symbs目录下(如: X:\.symbs\)
  574. " 如果是Linux系统, 则生成的文件在~/.symbs/目录下
  575. " 具体用法可参考www.vim.org中此插件的说明
  576. " <Leader>sy 自动生成tags与cscope文件并连接
  577. " <Leader>sc 连接已存在的tags与cscope文件
  578. " -----------------------------------------------------------------------------
  579. "  < cSyntaxAfter 插件配置 >
  580. " -----------------------------------------------------------------------------
  581. " 高亮括号与运算符等
  582. au! BufRead,BufNewFile,BufEnter *.{c,cpp,h,java,javascript} call CSyntaxAfter()
  583. " -----------------------------------------------------------------------------
  584. "  < ctrlp.vim 插件配置 >
  585. " -----------------------------------------------------------------------------
  586. " 一个全路径模糊文件,缓冲区,最近最多使用,... 检索插件;详细帮助见 :h ctrlp
  587. " 常规模式下输入:Ctrl + p 调用插件
  588. " -----------------------------------------------------------------------------
  589. "  < emmet-vim(前身为Zen coding) 插件配置 >
  590. " -----------------------------------------------------------------------------
  591. " HTML/CSS代码快速编写神器,详细帮助见 :h emmet.txt
  592. " -----------------------------------------------------------------------------
  593. "  < indentLine 插件配置 >
  594. " -----------------------------------------------------------------------------
  595. " 用于显示对齐线,与 indent_guides 在显示方式上不同,根据自己喜好选择了
  596. " 在终端上会有屏幕刷新的问题,这个问题能解决有更好了
  597. " 开启/关闭对齐线
  598. nmap <leader>il :IndentLinesToggle<CR>
  599. " 设置Gvim的对齐线样式
  600. if g:isGUI
  601. let g:indentLine_char = "┊"
  602. let g:indentLine_first_char = "┊"
  603. endif
  604. " 设置终端对齐线颜色,如果不喜欢可以将其注释掉采用默认颜色
  605. let g:indentLine_color_term = 239
  606. " 设置 GUI 对齐线颜色,如果不喜欢可以将其注释掉采用默认颜色
  607. " let g:indentLine_color_gui = '#A4E57E'
  608. " -----------------------------------------------------------------------------
  609. "  < vim-javacompleteex(也就是 javacomplete 增强版)插件配置 >
  610. " -----------------------------------------------------------------------------
  611. " java 补全插件
  612. " -----------------------------------------------------------------------------
  613. "  < Mark--Karkat(也就是 Mark) 插件配置 >
  614. " -----------------------------------------------------------------------------
  615. " 给不同的单词高亮,表明不同的变量时很有用,详细帮助见 :h mark.txt
  616. " " -----------------------------------------------------------------------------
  617. " "  < MiniBufExplorer 插件配置 >
  618. " " -----------------------------------------------------------------------------
  619. " " 快速浏览和操作Buffer
  620. " " 主要用于同时打开多个文件并相与切换
  621. " " let g:miniBufExplMapWindowNavArrows = 1     "用Ctrl加方向键切换到上下左右的窗口中去
  622. " let g:miniBufExplMapWindowNavVim = 1        "用<C-k,j,h,l>切换到上下左右的窗口中去
  623. " let g:miniBufExplMapCTabSwitchBufs = 1      "功能增强(不过好像只有在Windows中才有用)
  624. " "                                            <C-Tab> 向前循环切换到每个buffer上,并在但前窗口打开
  625. " "                                            <C-S-Tab> 向后循环切换到每个buffer上,并在当前窗口打开
  626. " 在不使用 MiniBufExplorer 插件时也可用<C-k,j,h,l>切换到上下左右的窗口中去
  627. noremap <c-k> <c-w>k
  628. noremap <c-j> <c-w>j
  629. noremap <c-h> <c-w>h
  630. noremap <c-l> <c-w>l
  631. " -----------------------------------------------------------------------------
  632. "  < neocomplcache 插件配置 >
  633. " -----------------------------------------------------------------------------
  634. " 关键字补全、文件路径补全、tag补全等等,各种,非常好用,速度超快。
  635. let g:neocomplcache_enable_at_startup = 1     "vim 启动时启用插件
  636. " let g:neocomplcache_disable_auto_complete = 1 "不自动弹出补全列表
  637. " 在弹出补全列表后用 <c-p> 或 <c-n> 进行上下选择效果比较好
  638. " -----------------------------------------------------------------------------
  639. "  < nerdcommenter 插件配置 >
  640. " -----------------------------------------------------------------------------
  641. " 我主要用于C/C++代码注释(其它的也行)
  642. " 以下为插件默认快捷键,其中的说明是以C/C++为例的,其它语言类似
  643. " <Leader>ci 以每行一个 /* */ 注释选中行(选中区域所在行),再输入则取消注释
  644. " <Leader>cm 以一个 /* */ 注释选中行(选中区域所在行),再输入则称重复注释
  645. " <Leader>cc 以每行一个 /* */ 注释选中行或区域,再输入则称重复注释
  646. " <Leader>cu 取消选中区域(行)的注释,选中区域(行)内至少有一个 /* */
  647. " <Leader>ca 在/*...*/与//这两种注释方式中切换(其它语言可能不一样了)
  648. " <Leader>cA 行尾注释
  649. let NERDSpaceDelims = 1                     "在左注释符之后,右注释符之前留有空格
  650. " -----------------------------------------------------------------------------
  651. "  < nerdtree 插件配置 >
  652. " -----------------------------------------------------------------------------
  653. " 有目录村结构的文件浏览插件
  654. " 常规模式下输入 F2 调用插件
  655. "nmap <F2> :NERDTreeToggle<CR>
  656. " -----------------------------------------------------------------------------
  657. "  < omnicppcomplete 插件配置 >
  658. " -----------------------------------------------------------------------------
  659. " 用于C/C++代码补全,这种补全主要针对命名空间、类、结构、共同体等进行补全,详细
  660. " 说明可以参考帮助或网络教程等
  661. " 使用前先执行如下 ctags 命令(本配置中可以直接使用 ccvext 插件来执行以下命令)
  662. " ctags -R --c++-kinds=+p --fields=+iaS --extra=+q
  663. " 我使用上面的参数生成标签后,对函数使用跳转时会出现多个选择
  664. " 所以我就将--c++-kinds=+p参数给去掉了,如果大侠有什么其它解决方法希望不要保留呀
  665. filetype plugin on
  666. set completeopt=menu                        "关闭预览窗口
  667. set nocp
  668. set ofu=syntaxcomplete#Complete
  669. set tags+=tags
  670. set completeopt=menu,longest,menuone
  671. let OmniCpp_NamespaceSearch=2
  672. let OmniCpp_GlobalScopeSearch=1
  673. let OmniCpp_ShowAccess=1
  674. let OmniCpp_ShowPrototypeInAbbr=1
  675. let OmniCpp_MayCompleteDot=1
  676. let OmniCpp_MayCompleteArrow=1
  677. let OmniCpp_MayCompleteScope=1
  678. let OmniCpp_DefaultNamespaces=["std", "_GLIBCXX_STD"]
  679. let OmniCpp_SelectFirstItem=2
  680. let OmniCpp_DisplayMode=1
  681. au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
  682. " -----------------------------------------------------------------------------
  683. "  < powerline 插件配置 >
  684. " -----------------------------------------------------------------------------
  685. " 状态栏插件,更好的状态栏效果
  686. " -----------------------------------------------------------------------------
  687. "  < repeat 插件配置 >
  688. " -----------------------------------------------------------------------------
  689. " 主要用"."命令来重复上次插件使用的命令
  690. " -----------------------------------------------------------------------------
  691. "  < snipMate 插件配置 >
  692. " -----------------------------------------------------------------------------
  693. " 用于各种代码补全,这种补全是一种对代码中的词与代码块的缩写补全,详细用法可以参
  694. " 考使用说明或网络教程等。不过有时候也会与 supertab 插件在补全时产生冲突,如果大
  695. " 侠有什么其它解决方法希望不要保留呀
  696. " -----------------------------------------------------------------------------
  697. "  < SrcExpl 插件配置 >
  698. " -----------------------------------------------------------------------------
  699. " 增强源代码浏览,其功能就像Windows中的"Source Insight"
  700. "nmap <F3> :SrcExplToggle<CR>                "打开/闭浏览窗口
  701. " -----------------------------------------------------------------------------
  702. "  < std_c 插件配置 >
  703. " -----------------------------------------------------------------------------
  704. " 用于增强C语法高亮
  705. " 启用 // 注视风格
  706. let c_cpp_comments = 0
  707. " -----------------------------------------------------------------------------
  708. "  < surround 插件配置 >
  709. " -----------------------------------------------------------------------------
  710. " 快速给单词/句子两边增加符号(包括html标签),缺点是不能用"."来重复命令
  711. " 不过 repeat 插件可以解决这个问题,详细帮助见 :h surround.txt
  712. " -----------------------------------------------------------------------------
  713. "  < Syntastic 插件配置 >
  714. " -----------------------------------------------------------------------------
  715. " 用于保存文件时查检语法
  716. " -----------------------------------------------------------------------------
  717. "  < Tagbar 插件配置 >
  718. " -----------------------------------------------------------------------------
  719. " 相对 TagList 能更好的支持面向对象
  720. " 常规模式下输入 tb 调用插件,如果有打开 TagList 窗口则先将其关闭
  721. nmap tb :TlistClose<CR>:TagbarToggle<CR>
  722. let g:tagbar_width=30                       "设置窗口宽度
  723. " let g:tagbar_left=1                         "在左侧窗口中显示
  724. " -----------------------------------------------------------------------------
  725. "  < TagList 插件配置 >
  726. " -----------------------------------------------------------------------------
  727. " 高效地浏览源码, 其功能就像vc中的workpace
  728. " 那里面列出了当前文件中的所有宏,全局变量, 函数名等
  729. " 常规模式下输入 tl 调用插件,如果有打开 Tagbar 窗口则先将其关闭
  730. nmap tl :TagbarClose<CR>:Tlist<CR>
  731. let Tlist_Show_One_File=1                   "只显示当前文件的tags
  732. " let Tlist_Enable_Fold_Column=0              "使taglist插件不显示左边的折叠行
  733. let Tlist_Exit_OnlyWindow=1                 "如果Taglist窗口是最后一个窗口则退出Vim
  734. let Tlist_File_Fold_Auto_Close=1            "自动折叠
  735. let Tlist_WinWidth=30                       "设置窗口宽度
  736. let Tlist_Use_Right_Window=1                "在右侧窗口中显示
  737. " -----------------------------------------------------------------------------
  738. "  < txtbrowser 插件配置 >
  739. " -----------------------------------------------------------------------------
  740. " 用于文本文件生成标签与与语法高亮(调用TagList插件生成标签,如果可以)
  741. au BufRead,BufNewFile *.txt setlocal ft=txt
  742. " -----------------------------------------------------------------------------
  743. "  < ZoomWin 插件配置 >
  744. " -----------------------------------------------------------------------------
  745. " 用于分割窗口的最大化与还原
  746. " 常规模式下按快捷键 <c-w>o 在最大化与还原间切换
  747. " =============================================================================
  748. "                          << 以下为常用工具配置 >>
  749. " =============================================================================
  750. " -----------------------------------------------------------------------------
  751. "  < cscope 工具配置 >
  752. " -----------------------------------------------------------------------------
  753. " 用Cscope自己的话说 - "你可以把它当做是超过频的ctags"
  754. if has("cscope")
  755. "设定可以使用 quickfix 窗口来查看 cscope 结果
  756. set cscopequickfix=s-,c-,d-,i-,t-,e-
  757. "使支持用 Ctrl+]  和 Ctrl+t 快捷键在代码间跳转
  758. set cscopetag
  759. "如果你想反向搜索顺序设置为1
  760. set csto=0
  761. "在当前目录中添加任何数据库
  762. if filereadable("cscope.out")
  763. cs add cscope.out
  764. "否则添加数据库环境中所指出的
  765. elseif $CSCOPE_DB != ""
  766. cs add $CSCOPE_DB
  767. endif
  768. set cscopeverbose
  769. "快捷键设置
  770. nmap ss :cs find s <C-R>=expand("<cword>")<CR><CR>
  771. nmap sg :cs find g <C-R>=expand("<cword>")<CR><CR>
  772. nmap sc :cs find c <C-R>=expand("<cword>")<CR><CR>
  773. nmap st :cs find t <C-R>=expand("<cword>")<CR><CR>
  774. nmap se :cs find e <C-R>=expand("<cword>")<CR><CR>
  775. nmap sf :cs find f <C-R>=expand("<cfile>")<CR><CR>
  776. nmap si :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
  777. nmap sd :cs find d <C-R>=expand("<cword>")<CR><CR>
  778. endif
  779. " -----------------------------------------------------------------------------
  780. "  < ctags 工具配置 >
  781. " -----------------------------------------------------------------------------
  782. " 对浏览代码非常的方便,可以在函数,变量之间跳转等
  783. set tags=./tags;                            "向上级目录递归查找tags文件(好像只有在Windows下才有用)
  784. " -----------------------------------------------------------------------------
  785. "< winManager 工具配置 >
  786. " -----------------------------------------------------------------------------
  787. let g:AutoOpenWinManager=1
  788. let g:winManagerWindowLayout='FileExplorer|TagList'
  789. nmap wm :WMToggle<cr>
  790. map <silent> <F3> :WMToggle<cr>
  791. " -----------------------------------------------------------------------------
  792. "  < gvimfullscreen 工具配置 > 请确保已安装了工具
  793. " -----------------------------------------------------------------------------
  794. " 用于 Windows Gvim 全屏窗口,可用 F11 切换
  795. " 全屏后再隐藏菜单栏、工具栏、滚动条效果更好
  796. if (g:iswindows && g:isGUI)
  797. nmap <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>
  798. endif
  799. " -----------------------------------------------------------------------------
  800. "  < vimtweak 工具配置 > 请确保以已装了工具
  801. " -----------------------------------------------------------------------------
  802. " 这里只用于窗口透明与置顶
  803. " 常规模式下 Ctrl + Up(上方向键) 增加不透明度,Ctrl + Down(下方向键) 减少不透明度,<Leader>t 窗口置顶与否切换
  804. if (g:iswindows && g:isGUI)
  805. let g:Current_Alpha = 255
  806. let g:Top_Most = 0
  807. func! Alpha_add()
  808. let g:Current_Alpha = g:Current_Alpha + 10
  809. if g:Current_Alpha > 255
  810. let g:Current_Alpha = 255
  811. endif
  812. call libcallnr("vimtweak.dll","SetAlpha",g:Current_Alpha)
  813. endfunc
  814. func! Alpha_sub()
  815. let g:Current_Alpha = g:Current_Alpha - 10
  816. if g:Current_Alpha < 155
  817. let g:Current_Alpha = 155
  818. endif
  819. call libcallnr("vimtweak.dll","SetAlpha",g:Current_Alpha)
  820. endfunc
  821. func! Top_window()
  822. if  g:Top_Most == 0
  823. call libcallnr("vimtweak.dll","EnableTopMost",1)
  824. let g:Top_Most = 1
  825. else
  826. call libcallnr("vimtweak.dll","EnableTopMost",0)
  827. let g:Top_Most = 0
  828. endif
  829. endfunc
  830. "快捷键设置
  831. nmap <c-up> :call Alpha_add()<CR>
  832. nmap <c-down> :call Alpha_sub()<CR>
  833. nmap <leader>t :call Top_window()<CR>
  834. endif
  835. " -----------------------------------------------------------------------------
  836. "  < 自动注释 工具配置 >
  837. " -----------------------------------------------------------------------------
  838. map fg : Dox<cr>
  839. let g:DoxygenToolkit_authorName="zhangbo E-mail:zhangbo@hisome.com"
  840. let g:DoxygenToolkit_licenseTag="My own license\<enter>"
  841. let g:DoxygenToolkit_undocTag="DOXIGEN_SKIP_BLOCK"
  842. let g:DoxygenToolkit_briefTag_pre = "@brief\t"
  843. let g:DoxygenToolkit_paramTag_pre = "@param\t"
  844. let g:DoxygenToolkit_returnTag = "@return\t"
  845. let g:DoxygenToolkit_briefTag_funcName = "no"
  846. let g:DoxygenToolkit_maxFunctionProtoLines = 30
  847. " =============================================================================
  848. "                          << 以下为常用自动命令配置 >>
  849. " =============================================================================
  850. " 自动切换目录为当前编辑文件所在目录
  851. au BufRead,BufNewFile,BufEnter * cd %:p:h
  852. " =============================================================================
  853. "                          << 其它 >>
  854. " =============================================================================
  855. " 注:上面配置中的"<Leader>"在本软件中设置为"\"键(引号里的反斜杠),如<Leader>t
  856. " 指在常规模式下按"\"键加"t"键,这里不是同时按,而是先按"\"键后按"t"键,间隔在一
  857. " 秒内,而<Leader>cs是先按"\"键再按"c"又再按"s"键;如要修改"<leader>"键,可以把
  858. " 下面的设置取消注释,并修改双引号中的键为你想要的,如修改为逗号键。
  859. " let mapleader = ","

我的vim的vimrc配置文件,保存用 - 飞在天空的鱼 - 博客频道相关推荐

  1. html svg导出图片,将SVG保存为图片_唐霜的博客

    原文:http://techslides.com/save-svg-as-an-image SVG超赞,但是有的时候你想把它转换为其他的图片格式,比如jpg或png.如果你用d3.js创建了一些图表, ...

  2. VIM学习笔记 配置文件(vimrc)

    为什么80%的码农都做不了架构师?>>>    VIM学习笔记 配置文件(vimrc) 在vim启动过程中,首先将查找配置文件并执行其中的命令.而这些初始化文件一般有vimrc.gv ...

  3. Shell开发环境vim编辑器的配置文件vimrc的参数优化

    Linux环境下为了方便Shell的开发,对配置文件vimrc的参数需要进行一些的优化,vim编辑器的配置文件默认路径为:~/.vimrc(全局路径为/etc/vimrc). 参数如下: " ...

  4. php vimrc配置文件,vim技巧:我的 .vimrc 配置文件,详解每一个配置项的作用

    下面是我的 .vimrc 配置文件,每一个配置项都添加了注释说明,详解每一个配置项的作用,以便确认为什么要添加这个配置项. " 使用vim的modeline来设置当前文件的textwidth ...

  5. Vim 3 vimrc

    文章目录 什么是 vimrc 基本修改 UI 相关配置 编码相关配置 文件相关配置 编辑器相关配置 按键映射 `` 键 我的 vimrc 小结 什么是 vimrc vimrc 是 Vim 的配置文件, ...

  6. vim自定义设置-配置文件

    http://blog.csdn.net/pipisorry/article/details/25056909 .vimrc配置文件表示说明 vim自定义键盘映射 使用:map命令,可以将键盘上的某个 ...

  7. 我现在的vimrc配置文件

    我现在的vimrc配置文件 runtime! debian.vim "设置编码 set encoding=utf-8 set fencs=utf-8,ucs-bom,shift-jis,gb ...

  8. [转载]Mac使用vim命令修改配置文件内容

    在服务器上部署服务,需要用到jar包起服务,但是不可避免的jar内容有时候需要自己修改配置来适用不同的服务器所在的一个网络环境. 不同于windows修改jar包配置文件内容:用压缩工具直接打开jar ...

  9. linux vim 强制退出 不保存

    linux vim 强制退出不保存T

  10. Vim——文件打开、保存、退出命令总结

    一.打开命令 vim filename 二.保存.退出命令 按 ESC,左下角就可以进行输入 命令 功能 :wq 保存并退出 :w 保存但不退出 :q 退出 :q! 强制退出,不保存 :e! 放弃所有 ...

最新文章

  1. Oracle 常见的33个等待事件
  2. 《软件构架实践》7-9章读后感
  3. 【vuejs路由】vuejs 路由基础入门实战操作详细指南
  4. MATLAB——阈值分割(一)
  5. ASP.NET MVC控制器获取前端视图FORM表单的方法
  6. 绿盟防火墙配置手册_双链路环境下不同品牌防火墙更换案例分享
  7. 实体摘要系统的解释性评测
  8. [转]Spring3 MVC + jQuery easyUI 做的ajax版本用户管理
  9. IPQ8072开机wifi crash问题
  10. Windows环境搭建Red5流媒体服务器
  11. Windows新建文本文档的快捷键设置
  12. ae输出quicktime设置_AE设置渲染输出视频及视频格式技巧教程
  13. python批量处理word格式_python自动化办公(V1.0)批量修改word文档格式
  14. Taylor’s Formula - 泰勒公式
  15. Unity3D纯白(Pure White)烘焙【2020】
  16. 台式计算机无法连接网络,台式电脑无法连接无线网络怎么办
  17. 【数据结构】串(一)—— 串的基础知识
  18. android t9搜索算法,T9拨号盘搜索和排序算法
  19. Excel也可以播放MV
  20. 我的生词表(中文在上,英文在下)(A-Z排序)

热门文章

  1. 谁说大象不能跳舞——《读书笔记》
  2. vrp java_在VRP平台上,直连路由、静态路由、RIP、OSPF的默认协议优先级从高到低的排序是( )。...
  3. python15 文件操作
  4. 把手机自带计算机软件,怎样删除手机自带软件
  5. 我的河海大学计算机考研经验之谈
  6. mysql frm怎么打开_frm 文件怎么打开?
  7. css3图片放大溢出,用canvas调整图像大小 - css溢出问题
  8. HiWork发布1.7.0新版本——可开启频道公开链接,增加HiWork客服功能及集成应用麦客
  9. snakemake--我最喜欢的流程管理工具
  10. 在字典中查找兄弟单词