Chinaunix首页 | 论坛 | 博客
  • 博客访问: 12617
  • 博文数量: 1
  • 博客积分: 98
  • 博客等级: 民兵
  • 技术积分: 30
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-22 00:35
文章分类

全部博文(1)

文章存档

2012年(1)

我的朋友
最近访客

分类: Python/Ruby

2012-04-22 23:04:04


IceVim配置Github地址


IceVim
-------------------------------------------------------------------------------
1. The .vimrc and fonts is used in both Windows and Linux.


2. The vimfiles, dict, tools is used in Windows.


    You may need to change your vimpath in .vimrc if your vimpath is not
  "D:\vim" in Windows.


3. The .vim is used in Linux.


    If you want use it in Linux, you need rename it like this:


```
cd ~
mv .vimrc .vimrc.bak
mv .vim .vim.bak
git clone IceVim
cd IceVim
mv .vim/ .vimrc  ~
cd ~
```


By the way, you need to install ctags, cscope, indent, gcc, gdb, make and so on,
  or you may get some error messages.



点击(此处)折叠或打开

  1. "Last Modified: 2018-04-03 11:39:03

  2. "当由Vim修改本文件保存时,自动更新本文件的修改日期
  3. au BufWritePre .vimrc norm mVMmmggf2C^R=strftime("%Y-%m-%d %H:%M:%S")^M^['m`V
  4. "Notice: ^R is ^M is ^[ is when input this command into this file.
  5. "Notice: ^R is ^M is ^[ is when you type this command by hand.

  6. "不使用vi兼容模式
  7. set nocompatible

  8. "返回系统类型 eg: Windows, or Linux, Mac, et.st..
  9. func! MySys()
  10.     if has("win16") || has("win32") || has("win64") || has("win95")
  11.         return "Windows"
  12.     elseif has("unix")
  13.         return "Linux"
  14.     endif
  15. endfunc

  16. if has("gui_running")
  17.     "设置GUI窗口位置
  18.     if MySys() == "Windows"
  19.         "1366x768
  20.         winpos 354 120
  21.         "1440x900
  22.         "winpos 392 180
  23.         "1920x1080
  24.         "winpos 630 280
  25.     elseif MySys() == "Linux"
  26.         winpos 360 150
  27.         "winpos 636 280
  28.     endif
  29.     "设置GUI窗口的大小
  30.     set lines=25
  31.     set columns=80
  32.     "设置菜单语言为默认的English
  33.     set langmenu=none
  34.     "调整窗口大小
  35.     set guioptions-=m " 隐藏菜单栏
  36.     set guioptions-=t " 隐藏菜单栏中的撕下此菜单
  37.     set guioptions-=T " 隐藏工具栏
  38.     set guioptions-=L " 隐藏左侧滚动条
  39.     set guioptions-=r " 隐藏右侧滚动条
  40.     set guioptions-=b " 隐藏底部滚动条
  41.     set showtabline=0 " 隐藏Tab栏
  42.     ""字体相关设置
  43.     if MySys() == "Linux"
  44.         "显示的字体
  45.         set guifont=Monospace\ 10
  46.         "set guifont=Nimbus\ Mono\ L\ 10
  47.     elseif MySys() == "Windows"
  48.         "显示的字体
  49.         set guifont=Consolas:h11:cANSI
  50.     endif
  51.     "设置默认的当前目录为用户家目录
  52.     cd ~
  53. endif

  54. "窗口最大化
  55. "if has("win32")
  56. " au GUIEnter * simalt ~x
  57. "else
  58. " au GUIEnter * call MaximizeWindow()
  59. "endif
  60. "
  61. "function! MaximizeWindow()
  62. " silent !wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
  63. "endfunction

  64. "自动切换当前目录为当前文件所在的目录
  65. if exists("+autochdir")
  66.     set autochdir
  67. endif

  68. ""文件相关设置
  69. "侦测文件类型
  70. filetype on
  71. "载入文件类型插件
  72. filetype plugin on
  73. "为特定文件类型载入相关缩进文件
  74. filetype indent on

  75. "Vim内部使用的编码
  76. set enc=utf-8
  77. "文件编码设置fileencoding
  78. set fenc=utf-8
  79. "文件默认换行符为unix的\n即
  80. set fileformat=unix
  81. "如果Linux系统编码包含GB(GBK,GB2312,GB18030), 则Vim内部编码cp936, 文件编码默认cp936
  82. if MySys() == "Linux" && match(toupper(system("echo $LANG")), "GB") > 0
  83.     "Vim内部使用的编码
  84.     set enc=cp936
  85.     "文件编码设置fileencoding
  86.     set fenc=cp936
  87. endif
  88. "把所有不明宽度的字符的宽度置为双倍字符宽度
  89. set ambiwidth=double
  90. "Vim自动探测fileencoding的顺序列表
  91. set fencs=ucs-bom,utf-8,gbk,cp936,gb2312,gb18030,big5,euc-jp,euc-kr,latin1
  92. "解决菜单乱码
  93. "source $VIMRUNTIME/menu.vim
  94. "source $VIMRUNTIME/delmenu.vim
  95. "解决消息乱码
  96. "language mes zh_CN.utf-8

  97. ""Quickfix设置
  98. "Quickfix messages编码转换
  99. function! QfMakeConv()
  100.     let qflist = getqflist()
  101.     for i in qflist
  102.         let i.text = iconv(i.text, "cp936", "utf-8")
  103.     endfor
  104.     call setqflist(qflist)
  105. endfunction
  106. if MySys() == "Windows"
  107.     au QuickfixCmdPost make call QfMakeConv()
  108. endif
  109. "没有错误和警告时,QuickFix窗口自动关闭
  110. au QuickfixCmdPost make call QfAutoDisplay()
  111. function! QfAutoDisplay()
  112.     if getqflist() == []
  113.         cclose
  114.     else
  115.         copen 10
  116.     endif
  117. endfunction
  118. " QuickFixExitOnlyWindow when QuickFix window is lonely present.
  119. "au BufEnter [Quickfix List] call QfExitOnlyWindow()
  120. "function! QfExitOnlyWindow()
  121. " " Before quitting Vim, delete the QuickFix buffer so that
  122. " " the '0 mark is correctly set to the previous buffer.
  123. " if &buftype == "quickfix"
  124. " if winbufnr(2) == -1
  125. " if tabpagenr('$') == 1
  126. " " Only one Quickfix page is present
  127. " bdelete
  128. " quit
  129. " else
  130. " " More than one tab page is present. Close only the current tab page
  131. " close
  132. " endif
  133. " endif
  134. " endif
  135. "endfunction

  136. "设置w可以包含的字符
  137. "set iskeyword=@,48-57,_,.
  138. "编辑一个文件时,直接用相应类型的iskeyword
  139. if has("autocmd")
  140.     "autocmd FileType c,cpp set iskeyword=@,48-57,_,.,-,>
  141.     autocmd FileType c,cpp set iskeyword=@,48-57,_
  142. endif

  143. "历史记录数
  144. set history=1000
  145. "覆盖文件时不备份文件
  146. set nobackup
  147. "在处理未保存或只读文件的时候,弹出确认
  148. set confirm

  149. ""显示相关设置
  150. "显示状态栏 (默认值为 1, 单个文件无法显示状态栏)
  151. set laststatus=2
  152. " 增强模式中的命令行自动完成操作
  153. set wildmenu
  154. "显示未完成的命令
  155. set showcmd
  156. "在编辑过程中,在右下角显示光标位置的状态行
  157. "set ruler
  158. "由于使用了airline插件,故不在底行显示当前所处的模式
  159. set noshowmode
  160. "光标所在的行出现一条淡色的线,更容易找到光标的所在位置
  161. "set cursorline

  162. "语法高亮
  163. syntax enable
  164. syntax on

  165. "高亮显示搜索结果
  166. set hlsearch
  167. "对输入要搜索的文字实时匹配
  168. set incsearch

  169. "允许backspace和光标键跨越行边界
  170. set backspace=indent,eol,start
  171. set whichwrap+=<,>,[,],h,l

  172. "继承前一行的缩进方式,特别适用于多行注释
  173. set autoindent
  174. "粘贴时不自动添加缩进
  175. "set paste
  176. "开启C语言缩进
  177. set cindent
  178. "开启新行时使用智能自动缩进
  179. set smartindent
  180. "自动匹配( )[ ]、{ },时间0.2秒
  181. set showmatch
  182. set matchtime=2
  183. "设置光标超过 78 列的时候折行
  184. "set textwidth=78
  185. "防止特殊符号无法正常显示
  186. set ambiwidth=double
  187. "显示最多行,不显示多行的@
  188. set display=lastline

  189. "分割窗口时保持相等的宽/高
  190. set equalalways
  191. if has("autocmd")
  192.     autocmd VimResized * normal ^W=
  193. endif

  194. "设置折叠
  195. if has("syntax")
  196.     "默认不折叠
  197.     set foldenable!
  198.     "用缩进来定义折叠
  199.     set foldmethod=indent
  200.     "设定折叠的最大嵌套层数为1,仅用于"indent"和"syntax"折叠
  201.     set foldnestmax=1
  202.     "设置为在折叠上水平移动时打开折叠
  203.     set foldopen=hor
  204.     "设置为自动关闭折叠
  205.     "set foldclose=all
  206. endif

  207. "让TOhtml产生有CSS语法的html
  208. let html_use_css=1

  209. "编辑一个文件时,直接用相应的折叠风格
  210. if has("autocmd")
  211.     autocmd FileType htm,html,xhtml,xml,jsp set foldnestmax=16
  212. endif

  213. ""设置缩进和Tab
  214. set sw=8 sts=8 ts=8 smarttab
  215. set cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:0,=s,l0,b0,gs,hs,p0,t0,is,+s,c3,C0,/0,(2s,us,U0,w0,W0,m0,j1,J1,)20,*70,#0
  216. "编辑一个文件时,直接用相应的缩进风格
  217. if has("autocmd")
  218.     autocmd FileType c,cpp,go,make set sw=8 sts=8 ts=8 smarttab
  219.     autocmd FileType java,ant set sw=4 sts=4 ts=4 expandtab
  220.     autocmd FileType sh,python,perl,ruby,php set sw=4 sts=4 ts=4 expandtab
  221.     autocmd FileType htm,html,xhtml,xml,jsp set sw=4 sts=4 ts=4 expandtab
  222.     autocmd FileType vim,tex,latex,sql set sw=4 sts=4 ts=8 expandtab
  223. endif

  224. "Longline Linux 风格缩进
  225.  LL()
  226.     "设定缩进时的宽度为8
  227.     set shiftwidth=8
  228.     "使得按退格键时可以一次删掉8个空格
  229.     set softtabstop=8
  230.     "设定tab长度为8
  231.     set tabstop=8
  232.     "不将tab用空格替换
  233.     set noexpandtab
  234.     "将空格用tab替换
  235.     set smarttab
  236.     "设定 Vim 来如何进行缩进
  237.     set cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:0,=s,l0,b0,gs,hs,p0,t0,is,+s,c3,C0,/0,(2s,us,U0,w0,W0,m0,j1,J1,)20,*70,#0
  238.     "格式化代码
  239.     exec "normal =G"
  240.     exec "%!indent\ -linux\ -l256"
  241.     "用g/indent.*\_s$/norm 2dd去掉indent的Warning
  242.     exec "g\/indent\.\*\\_s\$\/norm 2dd"
  243.     exec "normal G"
  244. endfunc
  245. "Linux 风格缩进
  246. func! LT()
  247.     "设定缩进时的宽度为8
  248.     set shiftwidth=8
  249.     "使得按退格键时可以一次删掉8个空格
  250.     set softtabstop=8
  251.     "设定tab长度为8
  252.     set tabstop=8
  253.     "不将tab用空格替换
  254.     set noexpandtab
  255.     "将空格用tab替换
  256.     set smarttab
  257.     "设定 Vim 来如何进行缩进
  258.     set cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:0,=s,l0,b0,gs,hs,p0,t0,is,+s,c3,C0,/0,(2s,us,U0,w0,W0,m0,j1,J1,)20,*70,#0
  259.     "格式化代码
  260.     exec "normal =G"
  261.     exec "%!indent\ -linux"
  262.     exec "normal G"
  263. endfunc
  264. "K&R 风格缩进
  265. func! KR()
  266.     "设定缩进时的宽度为4
  267.     set shiftwidth=4
  268.     "使得按退格键时可以一次删掉4个空格
  269.     set softtabstop=4
  270.     "设定tab长度为8
  271.     set tabstop=8
  272.     "将tab用空格替换
  273.     set expandtab
  274.     "设定 Vim 来如何进行缩进
  275.     set cinoptions=>s,e0,n0,f0,{0,}0,^0,L2,:0,=s,l0,b0,gs,hs,p0,t0,is,+s,c3,C0,/0,(2s,us,U0,w0,W0,m0,j1,J1,)20,*70,#0
  276.     "格式化代码
  277.     exec "normal =G"
  278.     exec "%!indent\ -kr -nut"
  279.     exec "normal G"
  280. endfunc
  281. "MS 风格缩进
  282.  MS()
  283.     "设定缩进时的宽度为4
  284.     set shiftwidth=4
  285.     "使得按退格键时可以一次删掉4个空格
  286.     set softtabstop=4
  287.     "设定tab长度为8
  288.     set tabstop=8
  289.     "将tab用空格替换
  290.     set expandtab
  291.     "设定 Vim 来如何进行缩进
  292.     set cinoptions=>s,e0,n0,f0,{0,}0,^0,L2,:s,=s,l0,b0,gs,hs,p0,t0,is,+s,c3,C0,/0,(2s,us,U0,w0,W0,m0,j1,J1,)20,*70,#0
  293.     "格式化代码
  294.     exec "normal =G"
  295.     exec "%!indent\ -kr\ -bl\ -bli0\ -cli4 -nut"
  296.     exec "normal G"
  297. endfunc
  298. "GNU 风格缩进
  299. func! GNU()
  300.     "设定缩进时的宽度为2
  301.     set shiftwidth=2
  302.     "使得按退格键时可以一次删掉2个空格
  303.     set softtabstop=2
  304.     "设定tab长度为8
  305.     set tabstop=8
  306.     "将tab用空格替换
  307.     set expandtab
  308.     "设定 Vim 来如何进行缩进
  309.     set cinoptions=>s,e0,n0,f0,{s,}0,^0,:0,L-1,=s,l0,b0,gs,hs,p5,t0,is,+s,c3,C0,/0,(2s,us,U0,w0,W0,m0,j1,J1,)20,*70,#0
  310.     "格式化代码
  311.     exec "normal =G"
  312.     exec "%!indent"
  313.     exec "normal G"
  314. endfunc
  315. "go gofmt 风格缩进
  316.  GO()
  317.     "设定缩进时的宽度为8
  318.     set shiftwidth=8
  319.     "使得按退格键时可以一次删掉8个空格
  320.     set softtabstop=8
  321.     "设定tab长度为8
  322.     set tabstop=8
  323.     "不将tab用空格替换
  324.     set noexpandtab
  325.     "将空格用tab替换
  326.     set smarttab
  327.     "设定 Vim 来如何进行缩进
  328.     set cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:0,=s,l0,b0,gs,hs,p0,t0,is,+s,c3,C0,/0,(2s,us,U0,w0,W0,m0,j1,J1,)20,*70,#0
  329.     "格式化代码
  330.     exec "normal =G"
  331.     exec "%!gofmt"
  332.     exec "normal G"
  333. endfunc
  334. "Java Eclipse风格缩进
  335.  JE()
  336.     "设定缩进时的宽度为4
  337.     set shiftwidth=4
  338.     "使得按退格键时可以一次删掉4个空格
  339.     set softtabstop=4
  340.     "设定tab长度为4
  341.     set tabstop=4
  342.     "不将tab用空格替换
  343.     set noexpandtab
  344.     "将空格用tab替换
  345.     set smarttab
  346.     "设定 Vim 来如何进行缩进
  347.     set cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:0,=s,l0,b0,gs,hs,p0,t0,is,+s,c3,C0,/0,(2s,us,U0,w0,W0,m0,j1,J1,)20,*70,#0
  348.     "格式化代码 用4个空格缩进
  349.     exec "normal =G"
  350.     exec "%!astyle\ -A2 -I -U -Y -L -p -H -k3 -q"
  351.     "格式化代码 用tab缩进
  352.     "exec "%!astyle\ -A2 -I -U -Y -T4 -L -p -H -k3 -q"
  353.     exec "normal G"
  354. endfunc
  355. "DS 去行尾空格
  356.  DS()
  357.     if search('\s\+$', 'pw') > 0
  358.         "去掉行尾空格
  359.         exec "%s/\\s\\+$//"
  360.         exec "update"
  361.     endif
  362. endfunc
  363. "TS 将Tab转换为8个空格
  364.  TS()
  365.     if search('\t', 'pw') > 0
  366.         "将Tab转换为8个空格
  367.         exec "%s/\\t/ /g"
  368.     endif
  369. endfunc

  370. ""编译、调试、运行相关函数
  371. "Debug 调试期版本
  372. "编译c源文件
  373. func! CompileC()
  374.     exec "update"
  375.     set makeprg=gcc\ -g\ -Wall\ -o\ %<\ %
  376.     exec "make"
  377.     set makeprg=make
  378. endfunc

  379. "编译cpp源文件
  380.  CompileCpp()
  381.     exec "update"
  382.     set makeprg=g++\ -g\ -Wall\ -o\ %<\ %
  383.     exec "make"
  384.     set makeprg=make
  385. endfunc

  386. "编译java源文件
  387. func! CompileJava()
  388.     exec "update"
  389.     if search('^\s*package\s\+.*;$', 'pw') > 0
  390.         set makeprg=javac\ -g\ -d\ ../..\ %
  391.     else
  392.         set makeprg=javac\ -g\ -d\ .\ %
  393.     endif
  394.     exec "make"
  395.     set makeprg=make
  396. endfunc

  397. "编译go源文件
  398.  CompileGo()
  399.     exec "update"
  400.     set makeprg=go\ build\ %
  401.     exec "make"
  402.     set makeprg=make
  403. endfunc

  404. "汇编、连接asm源文件
  405. func! CompileAsm()
  406.     if MySys() == "Windows"
  407.         exec "update"
  408.         set makeprg=nasm\ -f\ elf\ -g\ -F\ stabs\ -o\ %<.o\ %
  409.         exec "make"
  410.         if getqflist() == []
  411.             set makeprg=ld\ -o\ %<.exe\ %<.o
  412.             exec "make"
  413.             set makeprg=make
  414.         endif
  415.     elseif MySys() == "Linux"
  416.         exec "update"
  417.         set makeprg=nasm\ -f\ elf\ -g\ -F\ stabs\ -o\ %<.o\ %
  418.         exec "make"
  419.         if getqflist() == []
  420.             set makeprg=ld\ -o\ %<\ %<.o
  421.             exec "make"
  422.             set makeprg=make
  423.         endif
  424.     endif
  425. endfunc

  426. "编译makefile项目
  427.  CompileMake()
  428.     exec "update"
  429.     set makeprg=make
  430.     exec "make\ -f\ %"
  431. endfunc

  432. "Release 最终的释放期版
  433. "编译C源文件
  434.  ReleaseCompileC()
  435.     exec "update"
  436.     set makeprg=gcc\ -Wall\ -O2\ -o\ %<\ %
  437.     exec "make"
  438.     set makeprg=make
  439. endfunc

  440. "编译C++源文件
  441. func! ReleaseCompileCpp()
  442.     exec "update"
  443.     set makeprg=g++\ -Wall\ -O2\ -o\ %<\ %
  444.     exec "make"
  445.     set makeprg=make
  446. endfunc

  447. "编译Java源文件
  448.  ReleaseCompileJava()
  449.     exec "update"
  450.     if search('^\s*package\s\+.*;$', 'pw') > 0
  451.         set makeprg=javac\ -d\ ../..\ %
  452.     else
  453.         set makeprg=javac\ -d\ .\ %
  454.     endif
  455.     exec "make"
  456.     set makeprg=make
  457. endfunc

  458. "编译ASM源文件
  459. func! ReleaseCompileAsm()
  460.     if MySys() == "Windows"
  461.         exec "update"
  462.         set makeprg=nasm\ -f\ elf\ -o\ %<.o\ %
  463.         exec "make"
  464.         if getqflist() == []
  465.             set makeprg=ld\ -o\ %<.exe\ %<.o
  466.             exec "make"
  467.             set makeprg=make
  468.         endif
  469.     elseif MySys() == "Linux"
  470.         exec "update"
  471.         set makeprg=nasm\ -f\ elf\ -o\ %<.o\ %
  472.         exec "make"
  473.         if getqflist() == []
  474.             set makeprg=ld\ -o\ %<\ %<.o
  475.             exec "make"
  476.             set makeprg=make
  477.         endif
  478.     endif
  479. endfunc

  480. "编译makefile项目
  481.  ReleaseCompileMake()
  482.     exec "update"
  483.     set makeprg=make
  484.     exec "make\ -f\ %"
  485. endfunc

  486. "编译LaTeX源文件
  487. func! CompileLaTeX()
  488.     exec "update"
  489.     let compilecmd="!latex"
  490.     let compileflag=""
  491.     exec compilecmd.compileflag." %"
  492.     "exec "w"
  493.     "set makeprg=latex\ %
  494.     "exec "make"
  495. endfunc

  496. "运行c、cpp、asm程序
  497. func! RunCCppAsm()
  498.     if MySys() == "Windows"
  499.         "exec "!.\\".expand("%<")
  500.         "exec "!start .\\".expand("%<")
  501.         exec "!start cmd /C \".\\".expand("%<")." && pause\""
  502.     elseif MySys() == "Linux"
  503.         exec "!./%<"
  504.     endif
  505. endfunc

  506. "运行java类文件
  507.  RunJava()
  508.     if MySys() == "Windows"
  509.         if search('^\s*package\s\+.*;$', 'pw') > 0
  510.             "exec "norm gg/package/s+8^M" | exec "!java " . expand('') . ".%<"
  511.             "exec "norm gg/package/s+8^M" | exec "!start java " . expand('') . ".%<"
  512.             "exec "norm gg/package/s+8^M" | exec "!start cmd /C \"java ".expand('').".%<"." && pause\""
  513.             exec "norm gg/package/s+8^M" | exec "!start cmd /C \"cd ../.. && java ".expand('').".%<"." && pause\""
  514.             exec "norm gg"
  515.         else
  516.             "exec "!java %<"
  517.             "exec "!start java %<"
  518.             "exec "!start cmd /K \"java %<\""
  519.             exec "!start cmd /C \"java %< && pause\""
  520.         endif
  521.     elseif MySys() == "Linux"
  522.         if search('^\s*package\s\+.*;$', 'pw') > 0
  523.             "exec "norm gg/package/s+8^M" | exec "!java " . expand('') . ".%<"
  524.             exec "norm gg/package/s+8^M" | exec "!cd ../.. && java ".expand('').".%<"
  525.             exec "norm gg"
  526.         else
  527.             exec "!java %<"
  528.         endif
  529.     endif
  530. endfunc

  531. "运行go源文件
  532.  RunGo()
  533.     exec "update"
  534.     exec "!go run %"
  535. endfunc

  536. "运行perl源文件
  537. func! RunPerl()
  538.     exec "update"
  539.     exec "!perl %"
  540. endfunc

  541. "运行python源文件
  542.  RunPython()
  543.     exec "update"
  544.     exec "!python %"
  545. endfunc

  546. "运行ruby源文件
  547. func! RunRuby()
  548.     exec "update"
  549.     exec "!ruby %"
  550. endfunc

  551. "预览htm、html、xhtml结果
  552.  RunHtml()
  553.     exec "update"
  554.     if MySys() == "Windows"
  555.         "exec "!start\ cmd\ /C\ \"%\""
  556.         exec "!start\ cmd\ /C\ \"".iconv(expand("%"), "utf-8", "cp936")."\""
  557.     elseif MySys() == "Linux"
  558.         exec "!firefox %"
  559.     endif
  560. endfunc

  561. "预览LaTex结果
  562.  RunLaTeX()
  563.     if MySys() == "Windows"
  564.         exec "!yap %<.dvi"
  565.     elseif MySys() == "Linux"
  566.         exec "!xdvi %<"
  567.     endif
  568. endfunc

  569. "根据文件类型自动选择相应的编译函数
  570. func! CompileCode()
  571.     if MySys() == "Linux"
  572.         hi Search term=reverse ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black
  573.     endif
  574.     if &filetype == "c"
  575.         exec "call CompileC()"
  576.     elseif &filetype == "cpp"
  577.         exec "call CompileCpp()"
  578.     elseif &filetype == "asm"
  579.         exec "call CompileAsm()"
  580.     elseif &filetype == "java"
  581.         exec "call CompileJava()"
  582.     elseif &filetype == "go"
  583.         exec "call CompileGo()"
  584.     elseif &filetype == "tex"
  585.         exec "call CompileLaTeX()"
  586.     elseif &filetype == "plaintex"
  587.         exec "call CompileLaTeX()"
  588.     elseif &filetype == "make"
  589.         exec "call CompileMake()"
  590.     elseif &filetype == "perl"
  591.         exec "call RunPerl()"
  592.     elseif &filetype == "python"
  593.         exec "call RunPython()"
  594.     elseif &filetype == "ruby"
  595.         exec "call RunRuby()"
  596.     endif
  597. endfunc

  598. "根据文件类型自动选择相应的编译函数
  599.  ReleaseCompileCode()
  600.     if &filetype == "c"
  601.         exec "call ReleaseCompileC()"
  602.     elseif &filetype == "cpp"
  603.         exec "call ReleaseCompileCpp()"
  604.     elseif &filetype == "asm"
  605.         exec "call ReleaseCompileAsm()"
  606.     elseif &filetype == "java"
  607.         exec "call ReleaseCompileJava()"
  608.     elseif &filetype == "tex"
  609.         exec "call TexToPdf()"
  610.     elseif &filetype == "plaintex"
  611.         exec "call TexToPdf()"
  612.     elseif &filetype == "make"
  613.         exec "call CompileMake()"
  614.     elseif &filetype == "perl"
  615.         exec "call RunPerl()"
  616.     elseif &filetype == "python"
  617.         exec "call RunPython()"
  618.     elseif &filetype == "ruby"
  619.         exec "call RunRuby()"
  620.     endif
  621. endfunc

  622.  DviToPdf()
  623.     if MySys() == "Windows"
  624.         exec "!dvipdfmx %<"
  625.     elseif MySys() == "Linux"
  626.         exec "!dvipdf %<.dvi"
  627.     endif
  628. endfun

  629.  TexToPdf()
  630.     exec "w"
  631.     exec "!pdflatex %"
  632. endfun

  633. "根据文件类型自动选择相应的调试器调试
  634. func! DebugCode()
  635.     if MySys() == "Windows"
  636.         if &filetype == "c"
  637.             exec "!start gdb %<"
  638.         elseif &filetype == "cpp"
  639.             exec "!start gdb %<"
  640.         elseif &filetype == "asm"
  641.             exec "!start gdb %<"
  642.         elseif &filetype == "java"
  643.             exec "!start jdb %<"
  644.         elseif &filetype == "make"
  645.             exec "normal gg/:<CR>:noh<CR>b"|exec "!start gdb " . expand('')
  646.         endif
  647.     elseif MySys() == "Linux"
  648.         if &filetype == "c"
  649.             exec "!gdb %<"
  650.         elseif &filetype == "cpp"
  651.             exec "!gdb %<"
  652.         elseif &filetype == "asm"
  653.             exec "!gdb %<"
  654.         elseif &filetype == "java"
  655.             exec "!jdb %<"
  656.         elseif &filetype == "make"
  657.             exec "normal gg/:<CR>:noh<CR>b"|exec "!gdb " . expand('')
  658.         endif
  659.     endif
  660. endfunc

  661. "运行可执行文件
  662.  RunResult()
  663.     if &filetype == "c"
  664.         exec "call RunCCppAsm()"
  665.     elseif &filetype == "cpp"
  666.         exec "call RunCCppAsm()"
  667.     elseif &filetype == "asm"
  668.         exec "call RunCCppAsm()"
  669.     elseif &filetype == "java"
  670.         exec "call RunJava()"
  671.     elseif &filetype == "go"
  672.         exec "call RunGo()"
  673.     elseif &filetype == "tex"
  674.         exec "call RunLaTeX()"
  675.     elseif &filetype == "plaintex"
  676.         exec "call RunLaTeX()"
  677.     elseif &filetype == "perl"
  678.         exec "!perl %"
  679.     elseif &filetype == "python"
  680.         exec "!python %"
  681.     elseif &filetype == "ruby"
  682.         exec "!ruby %"
  683.     elseif &filetype == "make"
  684.         exec "normal gg/::nohb"|exec '!' . expand('')
  685.     elseif &filetype == "html"
  686.         exec "call RunHtml()"
  687.     elseif &filetype == "xhtml"
  688.         exec "call RunHtml()"
  689.     elseif &filetype == "css"
  690.         exec "call RunHtml()"
  691.     elseif &filetype == "javascript"
  692.         exec "call RunHtml()"
  693.     endif
  694. endfunc

  695. if has("autocmd")
  696.     autocmd BufEnter *.pc set filetype=esqlc
  697.     autocmd BufReadPost,BufWritePost *.java call SetJavaRunType()
  698. endif
  699.  SetJavaRunType()
  700.     if search('^\s*package\s\+.*;$', 'pw') == 0
  701.         ":command! -nargs=? Run :!java %<
  702.         :command! -nargs=? Run :exe "!start cmd /C \"java %< && pause\""
  703.     else
  704.         ": -nargs=? Run :exe "normal gg/package/s+8:noh"|:exe "!java ".expand('').".%< "
  705.         : -nargs=? Run :exe "norm gg/package/s+8^M" |:exe "!start cmd /C \"cd .. && java ".expand('').".%<"." <args>"." && pause\""
  706.     endif
  707. endfunc

  708. ""设置快捷键
  709. "外观
  710. if has("gui_running")
  711.     "调整窗口大小
  712.     if MySys() == "Windows"
  713.         :command Long :set lines=36 columns=80 | winpos 353 35 | :normal ^W=
  714.         :command Short :set lines=25 columns=80 | winpos 353 120 | :normal ^W=
  715.         :command Middle :set lines=36 columns=115 | winpos 213 35 | :normal ^W=
  716.         ":command Long :set lines=36 columns=80 | winpos 630 164 | :normal ^W=
  717.         ":command Short :set lines=25 columns=80 | winpos 630 280 | :normal ^W=
  718.         ":command Middle :set lines=36 columns=115 | winpos 487 164 | :normal ^W=
  719.         :command Big :set lines=53 columns=237 | winpos 2 30 | :normal ^W=
  720.     elseif MySys() == "Linux"
  721.         :command Long :set lines=40 columns=80 | winpos 360 35
  722.         :command Short :set lines=25 columns=80 | winpos 360 150
  723.         :command Middle :set lines=40 columns=115 | winpos 222 35
  724.     endif
  725.     "设置:L执行的命令
  726.     :command L :Long
  727.     "设置:S执行的命令
  728.     :command S :Short
  729.     "设置:M执行的命令
  730.     :command M :Middle
  731.     "设置:B执行的命令
  732.     :command B :Big
  733.     ""Windows外观相关设置
  734.     if MySys() == "Windows"
  735.         "Shift+F5,Shift+F6,Shift+F7,Shift+F8 透明-不透明
  736.         map <S-F5> <Esc>:call libcallnr("vimtweak.dll", "SetAlpha", 120)<CR>:normal v:normal<ESC>
  737.         map <S-F6> <Esc>:call libcallnr("vimtweak.dll", "SetAlpha", 180)<CR>:normal v:normal<ESC>
  738.         map <S-F7> <Esc>:call libcallnr("vimtweak.dll", "SetAlpha", 220)<CR>:normal v:normal<ESC>
  739.         map <S-F8> <Esc>:call libcallnr("vimtweak.dll", "SetAlpha", 255)<CR>:normal v:normal<ESC>
  740.         imap <S-F5> <C-O>:call libcallnr("vimtweak.dll", "SetAlpha", 120)<CR>
  741.         imap <S-F6> <C-O>:call libcallnr("vimtweak.dll", "SetAlpha", 180)<CR>
  742.         imap <S-F7> <C-O>:call libcallnr("vimtweak.dll", "SetAlpha", 220)<CR>
  743.         imap <S-F8> <C-O>:call libcallnr("vimtweak.dll", "SetAlpha", 255)<CR>
  744.         ""TopMost Window:
  745.         " Enable
  746.         map :call libcallnr("vimtweak.dll", "EnableTopMost", 1):normal v:normal
  747.         imap :call libcallnr("vimtweak.dll", "EnableTopMost", 1)
  748.         "<F10> Disable
  749.         map <F10> <Esc>:call libcallnr("vimtweak.dll", "EnableTopMost", 0)<CR>:normal v:normal<ESC>
  750.         imap <F10> <C-O>:call libcallnr("vimtweak.dll", "EnableTopMost", 0)<CR>
  751.         ""FullScreen
  752.         " Enable Disable
  753.         map :windo set nu!:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)v
  754.         imap :call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0):windo set nu!
  755.     endif
  756. endif

  757. ""颜色主题适用于Windowns,Linux...
  758. if exists("+syntax")
  759.     if has("gui_running")
  760.         "主题默认设置
  761.         colorscheme torte
  762.     else
  763.         colorscheme desert
  764.     endif
  765.     "colorscheme default
  766.     map :colorscheme defaultv
  767.     imap :colorscheme default
  768.     "colorscheme peachpuff
  769.     map <F6> <Esc>:colorscheme peachpuff<CR>v<Esc>
  770.     imap <F6> <C-O>:colorscheme peachpuff<CR>
  771.     "colorscheme desert
  772.     map :colorscheme darkslategreyv
  773.     imap :colorscheme darkslategrey
  774.     "colorscheme torte
  775.     map <F8> <Esc>:colorscheme torte<CR>v<Esc>
  776.     imap <F8> <C-O>:colorscheme torte<CR>
  777. endif

  778. "gh临时关闭高亮显示搜索结果
  779. map gh :noh:normal v:normal

  780. "gy系统剪切板复制
  781. map gy "+y
  782. "gy复制一个单词(从光标所在字符开始),可配合YouDao词典的剪切板监视功能查词
  783. "map gy "+ye
  784. "gY复制一个单词(到光标所在字符结束),可配合YouDao词典的剪切板监视功能查词
  785. "map gY my"+yb`y

  786. "2格缩进
  787. map g=2 :set sw=2 sts=2 ts=8 expandtab<CR>
  788. "4格缩进
  789. map g=4 :set sw=4 sts=4 ts=4 expandtab
  790. "8格缩进
  791. map g=8 :set sw=8 sts=8 ts=8 smarttab<CR>
  792. "Linux缩进风格 g=l
  793. map g=l :call LT()v
  794. "K&R缩进风格 g=k
  795. map g=k :call KR()<CR>v<Esc>
  796. "MS缩进风格 g=m
  797. map g=m :call MS()v
  798. "go gofmt缩进风格 g=g
  799. map g=g :call GO()<CR>v<Esc>
  800. "Java Eclipse缩进风格 g=j
  801. map g=j :call JE()v
  802. "DS去掉尾空 g=d
  803. map g=d :call DS()<CR>v<Esc>
  804. "TS将行首Tab转换为8个空格 g=s
  805. map g=s :call TS()v

  806. "格式化代码 g==
  807. map g== :call FF()<CR>v<Esc>
  808.  FF()
  809.     if &filetype == "c"
  810.         exec "call LL()"
  811.     elseif &filetype == "cpp"
  812.         exec "call LL()"
  813.     elseif &filetype == "java"
  814.         exec "call JE()"
  815.     elseif &filetype == "go"
  816.         exec "call GO()"
  817.     endif
  818. endfunc

  819.  MAP()
  820.     " gc 保存、编译
  821.     map gc :call CompileCode()
  822.     " gr 保存、运行
  823.     map gr :call RunResult()<CR>
  824.     " gl 调试
  825.     map gl :call DebugCode()
  826.     " gw 光标wrap到第一个错误或警告
  827.     map gw :cfirst<CR>
  828.     " gp 光标跳到上一个错误或警告
  829.     map gp :cprevious
  830.     " gn 光标跳到下一个错误或警告
  831.     map gn :cnext<CR>
  832.     " gs 释放
  833.     map gs :call ReleaseCompileCode()
  834. endfunc

  835. "编辑一个文件时,直接用相应的键盘映射
  836. if has("autocmd")
  837.     autocmd FileType c,cpp,java,go,make call MAP()
  838.     autocmd FileType python,perl,ruby,php call MAP()
  839.     autocmd FileType htm,html,xhtml,xml call MAP()
  840.     autocmd FileType vim,tex,latex call MAP()
  841. endif

  842. "一些不错的映射转换语法(如果在一个文件中混合了不同语言时有用)
  843. nmap 1 :set filetype=xhtml
  844. nmap 2 :set filetype=css
  845. nmap 3 :set filetype=javascript
  846. nmap 4 :set filetype=jsp
  847. nmap 5 :set filetype=php

  848. "":TOhtml的衍生版, :TH, :TW
  849. "修改默认的网页编码为UTF-8
  850. : TH :normal zn:TO^Mggjjj3f=lct"UTF-8^[grZZ
  851. "将配色置为默认配色白色
  852. : TW :color default |:color default |:TH

  853. "将本文件同步到需要同步的文件夹里
  854. :command! SC :w! G:/Download/.vimrc |:w! G:/百度云/我的配置文件/vimrc |:w! E:\code\GitHub\IceVim\.vimrc |:update

  855. "窗口分割时,进行切换的按键热键需要连接两次,比如从下方窗口移动
  856. "光标到上方窗口,需要k,非常麻烦,现在重映射为,切换的
  857. "时候会变得非常方便.
  858. "nnoremap h
  859. "nnoremap <C-J> <C-W>j
  860. "nnoremap k
  861. "nnoremap <C-L> <C-W>l

  862. "在插入模式下,输入Ctrl_L代替Delete
  863. "inoremap <C-L> <Del>
  864. "在插入模式下,模拟Emacs的
  865. inoremap zz

  866. ":命令模式下的一组tcsh风格的键
  867. :cnoremap <C-A> <Home>
  868. :cnoremap <C-E> <End>
  869. :cnoremap <C-F> <Right>
  870. :cnoremap <C-B> <Left>
  871. :cnoremap <C-H> <Backspace>
  872. :cnoremap <C-D> <Delete>

  873. " Alt-Space is System menu
  874. if has("gui")
  875.     noremap :simalt ~
  876.     inoremap :simalt ~
  877.     cnoremap :simalt ~
  878. endif

  879. " CTRL-Tab is Next Tab
  880. noremap <C-Tab> gt
  881. inoremap <C-Tab> <C-O>gt
  882. cnoremap <C-Tab> <C-C>gt
  883. onoremap <C-Tab> <C-C>gt

  884. " CTRL-Shift-Tab is Previous Tab
  885. noremap gT
  886. inoremap gT
  887. cnoremap gT
  888. onoremap gT

  889. ""目录设置
  890. "设置的头文件*.h所在目录
  891. if MySys() == "Windows"
  892.     set path+=D:\MinGW\include,D:\MinGW\lib\gcc\mingw32\4.7.2\include,
  893.                 \D:\MinGW\lib\gcc\mingw32\4.7.2\include\c++
  894. elseif MySys() == "Linux"
  895.     set path+=/usr/include/,/usr/include/c++/*/
  896. endif

  897. "当有多个同名函数时,需要选择
  898. noremap g
  899. "生成 tags命令: ctags -R --langmap=c:.c.pc .
  900. "在当前目录找不到tags文件时请到上层目录查找
  901. set tags=tags;/,.tags;/
  902. "如果觉得到处放置tags文件不好,可以设置tags目录
  903. "if MySys() == "Windows"
  904. " set tags=$Vim\tags
  905. "elseif MySys() == "Linux"
  906. " set tags=~/.tags/
  907. "endif

  908. "设置dictionary目录
  909. if MySys() == "Windows"
  910.     set dictionary=$Vim\dict\words
  911. elseif MySys() == "Linux"
  912.     set dictionary=/usr/share/dict/words
  913. endif

  914. ""插件的设置
  915. "---------- Taglist.vim [显示程序中的宏定义、变量、函数、类] ----------
  916. let Tlist_GainFocus_On_ToggleOpen=0
  917. let Tlist_WinWidth=34
  918. let Tlist_Exit_OnlyWindow=1
  919. let Tlist_File_Fold_Auto_Close=1
  920. let Tlist_Enable_Fold_Column=0
  921. let Tlist_Inc_Winwidth=0

  922. "---------- WinManager.vim [窗口管理] ----------
  923. let g:winManagerWindowLayout='FileExplorer|TagList'
  924. let g:winManagerWidth=34

  925. "--------------------Cscope设置--------------------
  926. "生成cscope.out命令: cscope -Rbkq
  927. if has("cscope")
  928.     if filereadable("cscope.out")
  929.         cs add cscope.out
  930.         "不自动设置当前目录为文件所在目录
  931.         set noautochdir
  932.     elseif $CSCOPE_DB != ""
  933.         cs add $CSCOPE_DB
  934.     endif
  935. endif

  936. "--------------------Airline设置--------------------
  937. set t_Co=256
  938. set ttimeoutlen=50
  939. let g:airline_theme='powerlineish'
  940. let g:airline_powerline_fonts=1
  941. "let g:airline#extensions#tabline#enabled = 1
  942. "let g:airline#extensions#whitespace#enabled=0
  943. "let g:airline#extensions#whitespace#symbol='!'
  944. set guifont=Consolas\ for\ Powerline\ FixedD:h11
  945. if !exists('g:airline_symbols')
  946.     let g:airline_symbols = {}
  947. endif
  948. if has("gui_running") && &enc == 'utf-8' && &fenc == 'utf-8'
  949.     let g:airline_left_sep = '?'
  950.     let g:airline_left_alt_sep = '?'
  951.     let g:airline_right_sep = '?'
  952.     let g:airline_right_alt_sep = '?'
  953.     let g:airline_symbols.branch = '?'
  954.     let g:airline_symbols.readonly = '?'
  955.     let g:airline_symbols.linenr = '?'
  956. else
  957.     let g:airline_left_sep = '>'
  958.     let g:airline_left_alt_sep = '>'
  959.     let g:airline_right_sep = '<'
  960.     let g:airline_right_alt_sep = '<'
  961.     let g:airline_symbols.branch = '|'
  962.     let g:airline_symbols.readonly = ''
  963.     let g:airline_symbols.linenr = 'LN'
  964. endif
  965. let g:airline_detect_paste=0
  966. let g:airline#extensions#default#section_truncate_width = {'b': 79, 'x': 60, 'y': 55, 'z': 45}
  967. let g:airline_section_z = '%3p%% %#__accent_bold#%{g:airline_symbols.linenr} %1l%#__restore__#:%1v'
  968. "let g:airline#extensions#tabline#enabled=1

  969. "--------------------bufexplore设置--------------------
  970. " 打开Buffer Explore
  971. "map gb :BufExplorer
  972. " gbp 前一个Buffer
  973. "map gbp :bprevious
  974. " gbn 后一个Buffer
  975. "map gbn :bnext
  976. "关闭缓冲区
  977. nnoremap g. :bd!>
  978. " Buffers操作快捷方式,模仿Tab操作的gt,gT
  979. nnoremap gb :bnext
  980. nnoremap gB :bNext

  981. "------------------NERD_commenter设置------------------
  982. map <C-Q> <plug>NERDCommenterToggle

  983. "------------------ZenCoding设置------------------
  984. "<C-\>,
  985. let g:user_zen_leader_key = ''

  986. ""插件的快捷键设置
  987. map <F2> <Esc>:NERDTreeToggle<CR>
  988. imap <F2> <C-O>NERDTreeToggle<CR>
  989. map <F3> <Esc>:TlistToggle<CR>:set nu!>
  990. imap <F3> <C-O>:TlistToggle<CR>:set nu!>
  991. map <F4> <Esc>:WMToggle<CR>:set nu!>
  992. imap <F4> <C-O>:WMToggle<CR>:set nu!>

阅读(1438) | 评论(2) | 转发(0) |
0

上一篇:没有了

下一篇:没有了

给主人留下些什么吧!~~

Black_Noodles2012-06-16 22:56:12

Mark下,vim有需求就来你这里,真全,吼吼

VimIcewind2012-04-28 16:28:38

不断完善中,欢迎提建议