Guest User

Untitled

a guest
Sep 9th, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.70 KB | None | 0 0
  1. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  2. " Vundle 插件管理
  3. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  4.  
  5. "set nocompatible
  6. "filetype off
  7. "set rtp+=~/.vim/bundle/vundle/
  8. "call vundle#rc()
  9. "Bundle 'gmarik/vundle'
  10. "Bundle 'kien/ctrip.vim'
  11.  
  12. "Bundle 'sukima/xmledit'
  13. "Bundle 'sjl/gundo.vim'
  14. "Bundle 'jiangmiao/auto-pairs'
  15. "Bundle 'klen/python-mode'
  16. "Bundle 'Valloric/ListToggle'
  17. "Bundle 'SirVer/ultisnips'
  18. "Bundle 'scrooloose/syntastic'
  19. "Bundle 't9md/vim-quickhl'
  20. "Bundle 'scrooloose/nerdcommenter'
  21.  
  22. "Bundle 'YankRing.vim'
  23. "Bundle 'vcscommand.vim'
  24. "Bundle 'ShowPairs'
  25. "Bundle 'SudoEdit.vim'
  26. "Bundle 'EasyGrep'
  27. "Bundle 'VOoM'
  28. "Bundle 'VimIM'
  29.  
  30. "filetype plugin indent on
  31.  
  32. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  33. " 显示相关
  34. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  35.  
  36. "set shortmess=atI " 启动的时候不显示那个援助乌干达儿童的提示
  37. "winpos 5 5 " 设定窗口位置
  38. "set lines=40 columns=155 " 设定窗口大小
  39. "set nu " 显示行号
  40. set go= " 不要图形按钮
  41. ""color asmanian2 " 设置背景主题
  42. set guifont=Courier_New:h10:cANSI " 设置字体
  43. syntax on " 语法高亮
  44. autocmd InsertLeave * se nocul " 用浅色高亮当前行
  45. autocmd InsertEnter * se cul " 用浅色高亮当前行
  46. "set ruler " 显示标尺
  47. set showcmd " 输入的命令显示出来,看的清楚些
  48. "set cmdheight=1 " 命令行(在状态行下)的高度,设置为1
  49. "set whichwrap+=<,>,h,l " 允许backspace和光标键跨越行边界(不建议)
  50. "set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离
  51. set novisualbell " 不要闪烁(不明白)
  52. set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} "状态行显示的内容
  53. set laststatus=1 " 启动显示状态行(1),总是显示状态行(2)
  54. set foldenable " 允许折叠
  55. set foldmethod=manual " 手动折叠
  56. "set background=dark "背景使用黑色
  57. set nocompatible "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
  58. " 显示中文帮助
  59. if version >= 603
  60. set helplang=cn
  61. set encoding=utf-8
  62. endif
  63. " 设置配色方案
  64. "colorscheme murphy
  65. "colorscheme freya
  66. "字体
  67. if (has("gui_running"))
  68. set guifont=Bitstream\ Vera\ Sans\ Mono\ 10
  69. endif
  70.  
  71.  
  72. set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
  73. set termencoding=utf-8
  74. set encoding=utf-8
  75. set fileencodings=ucs-bom,utf-8,cp936
  76. set fileencoding=utf-8
  77. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  78. """""新文件标题""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  79. "新建.c,.h,.sh,.java文件,自动插入文件头
  80. autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java,*.py *.fish exec ":call SetTitle()"
  81. ""定义函数SetTitle,自动插入文件头
  82. func SetTitle()
  83. "如果文件类型为.sh文件
  84. if &filetype == 'sh'
  85. call setline(1,"\#########################################################################")
  86. call append(line("."), "\# File Name: ".expand("%"))
  87. call append(line(".")+1, "\# Author: zhan")
  88. call append(line(".")+2, "\# Mail: zhandequanla00@gmail.com")
  89. call append(line(".")+3, "\# Created Time: ".strftime("%c"))
  90. call append(line(".")+4, "\#########################################################################")
  91. call append(line(".")+5, "\#!/bin/bash")
  92. call append(line(".")+6, "")
  93. elseif &filetype == 'cpp' || &filetype == 'c'
  94. call setline(1, "\/*************************************************************************")
  95. call append(line("."), " > File Name: ".expand("%"))
  96. call append(line(".")+1, " > Author: zhan")
  97. call append(line(".")+2, " > Mail: zhandequanla00@gmail.com ")
  98. call append(line(".")+3, " > Created Time: ".strftime("%c"))
  99. call append(line(".")+4, " ************************************************************************/")
  100. call append(line(".")+5, "")
  101. endif
  102. if &filetype == 'fish'
  103. call setline(1,"\#########################################################################")
  104. call append(line("."), "\# File Name: ".expand("%"))
  105. call append(line(".")+1, "\# Author: zhan")
  106. call append(line(".")+2, "\# Mail: zhandequanla00@gmail.com")
  107. call append(line(".")+3, "\# Created Time: ".strftime("%c"))
  108. call append(line(".")+4, "\#########################################################################")
  109. call append(line(".")+5, "\#!/usr/bin/fish")
  110. endif
  111. if &filetype == 'cpp'
  112. call append(line(".")+6, "#include<iostream>")
  113. call append(line(".")+7, "using namespace std;")
  114. call append(line(".")+8, "")
  115. endif
  116. if &filetype == 'c'
  117. call append(line(".")+6, "#include<stdio.h>")
  118. call append(line(".")+7, "")
  119. endif
  120. if &filetype == 'python'
  121. call setline(1, "\#!/usr/bin/env python3")
  122. call append(line("."), "\#-*- coding: utf-8 -*-")
  123. call append(line(".")+1, "")
  124. call append(line(".")+2, "__author__ = 'ZhanDequan'")
  125. call append(line(".")+3, "")
  126. call append(line(".")+4, "'''")
  127. call append(line(".")+5, "Descritpion")
  128. call append(line(".")+6, "'''")
  129. call append(line(".")+7, "")
  130. endif
  131. "新建文件后,自动定位到文件末尾
  132. autocmd BufNewFile * normal G
  133. endfunc
  134. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  135. "键盘命令
  136. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  137.  
  138. nmap <leader>w :w!<cr>
  139. nmap <leader>f :find<cr>
  140. " 映射全选+复制 ctrl+a
  141. map <C-A> ggVGY
  142. map! <C-A> <Esc>ggVGY
  143. map <F12> gg=G
  144. " 选中状态下 Ctrl+c 复制
  145. vmap <C-c> "+y
  146. "去空行
  147. nnoremap <F2> :g/^\s*$/d<CR>
  148. "比较文件
  149. nnoremap <C-F2> :vert diffsplit
  150. "新建标签
  151. map <M-F2> :tabnew<CR>
  152. "列出当前目录文件
  153. "map <F3> :tabnew .<CR>
  154. "nerdtree
  155. let NERDTreeChristmasTree=1
  156. let NERDTreeQuitOnOpen=1
  157. map <F3> :NERDTreeMirror<CR>
  158. map <F3> :NERDTreeToggle<CR>
  159. "打开树状文件目录
  160. map <C-F3> \be
  161. "C,C++ 按F5编译运行
  162. map <F5> :call CompileRunGcc()<CR>
  163. func! CompileRunGcc()
  164. exec "w"
  165. if &filetype == 'c'
  166. exec "!g++ % -o %<"
  167. exec "! ./%<"
  168. elseif &filetype == 'cpp'
  169. exec "!g++ % -o %<"
  170. exec "! ./%<"
  171. elseif &filetype == 'java'
  172. exec "!javac %"
  173. exec "!java %<"
  174. elseif &filetype == 'sh'
  175. :!./%
  176. endif
  177. endfunc
  178. "C,C++的调试
  179. map <F8> :call Rungdb()<CR>
  180. func! Rungdb()
  181. exec "w"
  182. exec "!g++ % -g -o %<"
  183. exec "!gdb ./%<"
  184. endfunc
  185. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  186. ""实用设置
  187. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  188. " 设置当文件被改动时自动载入
  189. set autoread
  190. " quickfix模式
  191. autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>
  192. "代码补全
  193. set completeopt=preview,menu
  194. "允许插件
  195. filetype plugin on
  196. "共享剪贴板
  197. set clipboard+=unnamed
  198. "从不备份
  199. set nobackup
  200. "make 运行
  201. :set makeprg=g++\ -Wall\ \ %
  202. "自动保存
  203. set autowrite
  204. set ruler " 打开状态栏标尺
  205. set cursorline " 突出显示当前行
  206. set magic " 设置魔术
  207. set guioptions-=T " 隐藏工具栏
  208. set guioptions-=m " 隐藏菜单栏
  209. "set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\
  210. " 设置在状态行显示的信息
  211. set foldcolumn=0
  212. set foldmethod=indent
  213. set foldlevel=3
  214. set foldenable " 开始折叠
  215. " 语法高亮
  216. set syntax=on
  217. " 去掉输入错误的提示声音
  218. set noeb
  219. " 在处理未保存或只读文件的时候,弹出确认
  220. set confirm
  221. " 自动缩进
  222. set autoindent
  223. set cindent
  224. " Tab键的宽度
  225. set tabstop=4
  226. " 统一缩进为4
  227. set softtabstop=4
  228. set shiftwidth=4
  229. " 不要用空格代替制表符
  230. set noexpandtab
  231. " 在行和段开始处使用制表符
  232. set smarttab
  233. " 显示行号
  234. set number
  235. " 设置行号相关
  236. set relativenumber
  237. " 历史记录数
  238. set history=1000
  239. "禁止生成临时文件
  240. set nobackup
  241. set noswapfile
  242. "搜索忽略大小写
  243. set ignorecase
  244. "搜索逐字符高亮
  245. set hlsearch
  246. set incsearch
  247. "行内替换
  248. set gdefault
  249. "编码设置
  250. set enc=utf-8
  251. set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
  252. "语言设置
  253. set langmenu=zh_CN.UTF-8
  254. set helplang=cn
  255. " 我的状态行显示的内容(包括文件类型和解码)
  256. "set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
  257. "set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%]
  258. " 总是显示状态行
  259. set laststatus=2
  260. " 命令行(在状态行下)的高度,默认为1,这里是2
  261. set cmdheight=2
  262. " 侦测文件类型
  263. filetype on
  264. " 载入文件类型插件
  265. filetype plugin on
  266. " 为特定文件类型载入相关缩进文件
  267. filetype indent on
  268. " 保存全局变量
  269. set viminfo+=!
  270. " 带有如下符号的单词不要被换行分割
  271. set iskeyword+=_,$,@,%,#,-
  272. " 字符间插入的像素行数目
  273. set linespace=0
  274. " 增强模式中的命令行自动完成操作
  275. set wildmenu
  276. " 使回格键(backspace)正常处理indent, eol, start等
  277. set backspace=2
  278. " 允许backspace和光标键跨越行边界
  279. set whichwrap+=<,>,h,l
  280. " 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
  281. set mouse=a
  282. set selection=exclusive
  283. set selectmode=mouse,key
  284. " 通过使用: commands命令,告诉我们文件的哪一行被改变过
  285. set report=0
  286. " 在被分割的窗口间显示空白,便于阅读
  287. set fillchars=vert:\ ,stl:\ ,stlnc:\
  288. " 高亮显示匹配的括号
  289. set showmatch
  290. " 匹配括号高亮的时间(单位是十分之一秒)
  291. set matchtime=1
  292. " 光标移动到buffer的顶部和底部时保持3行距离
  293. set scrolloff=3
  294. " 为C程序提供自动缩进
  295. set smartindent
  296. " 高亮显示普通txt文件(需要txt.vim脚本)
  297. au BufRead,BufNewFile * setfiletype txt
  298. "自动补全
  299. :inoremap ( ()<ESC>i
  300. :inoremap ) <c-r>=ClosePair(')')<CR>
  301. :inoremap { {<CR>}<ESC>O
  302. :inoremap } <c-r>=ClosePair('}')<CR>
  303. :inoremap [ []<ESC>i
  304. :inoremap ] <c-r>=ClosePair(']')<CR>
  305. :inoremap " ""<ESC>i
  306. :inoremap ' ''<ESC>i
  307. function! ClosePair(char)
  308. if getline('.')[col('.') - 1] == a:char
  309. return "\<Right>"
  310. else
  311. return a:char
  312. endif
  313. endfunction
  314. filetype plugin indent on
  315. "打开文件类型检测, 加了这句才可以用智能补全
  316. set completeopt=longest,menu
  317. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  318. " CTags的设定
  319. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  320. let Tlist_Sort_Type = "name" " 按照名称排序
  321. let Tlist_Use_Right_Window = 1 " 在右侧显示窗口
  322. let Tlist_Compart_Format = 1 " 压缩方式
  323. let Tlist_Exist_OnlyWindow = 1 " 如果只有一个buffer,kill窗口也kill掉buffer
  324. let Tlist_File_Fold_Auto_Close = 0 " 不要关闭其他文件的tags
  325. let Tlist_Enable_Fold_Column = 0 " 不要显示折叠树
  326. autocmd FileType python set omnifunc=pythoncomplete#Complete
  327. autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
  328. autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
  329. autocmd FileType css set omnifunc=csscomplete#CompleteTags
  330. autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
  331. "autocmd FileType java set tags+=D:\tools\java\tags
  332. "autocmd FileType h,cpp,cc,c set tags+=D:\tools\cpp\tags
  333. "let Tlist_Show_One_File=1 "不同时显示多个文件的tag,只显示当前文件的
  334. "设置tags
  335. set tags=tags
  336. "set autochdir
  337.  
  338. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  339. "其他东东
  340. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  341. "默认打开Taglist
  342. let Tlist_Auto_Open=1
  343. """"""""""""""""""""""""""""""
  344. " Tag list (ctags)
  345. """"""""""""""""""""""""""""""""
  346. let Tlist_Ctags_Cmd = '/usr/bin/ctags'
  347. let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的
  348. let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim
  349. let Tlist_Use_Right_Window = 1 "在右侧窗口中显示taglist窗口
  350. " minibufexpl插件的一般设置
  351. let g:miniBufExplMapWindowNavVim = 1
  352. let g:miniBufExplMapWindowNavArrows = 1
  353. let g:miniBufExplMapCTabSwitchBufs = 1
  354. let g:miniBufExplModSelTarget = 1
  355. "下载安装 youcompleteme
  356. "Bundle 'Valloric/YouCompleteMe'
  357. "Plugin 'fatih/vim-go'
  358. "
  359. "golang配置
  360. "filetype off
  361. "set rtp+=~/.vim/bundle/vundle/
  362. "call vundle#rc()
  363. "Plugin 'gmarik/vundle'
  364. "filetype plugin indent on
  365. "Bundle 'majutsushi/tagbar'
  366. "run macros/gdb_mapping.vim
  367. "filetype off
  368. "filetype plugin indent off
  369. "set runtimepath+=$GOROOT/misc/vim
  370. "filetype plugin indent on
  371. "syntax on
  372. "autocmd FileType go autocmd BufWritePre <buffer> Fmt
  373.  
  374. "代码补全
  375. "Bundle 'Blackrush/vim-gocode'
  376. "代码跳转
  377. "Bundle 'dgryski/vim-godef'
  378. "代码结构
  379. "Bundle 'majustsushi/tagbar'
  380. "nmap <F8> :TagbarToggle<CR>
  381. "let g:tagbar_type_go = {
  382. " \ 'ctagstype' : 'go',
  383. " \ 'kinds' : [
  384. " \ 'p:package',
  385. " \ 'i:imports:1',
  386. " \ 'c:constants',
  387. " \ 'v:variables',
  388. " \ 't:types',
  389. " \ 'n:interfaces',
  390. " \ 'w:fields',
  391. " \ 'e:embedded',
  392. " \ 'm:methods',
  393. " \ 'r:constructor',
  394. " \ 'f:functions'
  395. " \ ],
  396. " \ 'sro' : '.',
  397. " \ 'kind2scope' : {
  398. " \ 't' : 'ctype',
  399. " \ 'n' : 'ntype'
  400. " \ },
  401. " \ 'scope2kind' : {
  402. " \ 'ctype' : 't',
  403. " \ 'ntype' : 'n'
  404. " \ },
  405. " \ 'ctagsbin' : 'gotags',
  406. " \ 'ctagsargs' : '-sort -silent'
  407. "\ }
Add Comment
Please, Sign In to add comment