1. set nocompatible
  2. source $VIMRUNTIME/vimrc_example.vim
  3. source $VIMRUNTIME/mswin.vim
  4. behave mswin
  5. set nocompatible " 去除VI一致性,必须
  6. set diffexpr=MyDiff()
  7. function MyDiff()
  8. let opt = '-a --binary '
  9. if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  10. if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  11. let arg1 = v:fname_in
  12. if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  13. let arg2 = v:fname_new
  14. if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  15. let arg3 = v:fname_out
  16. if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  17. let eq = ''
  18. if $VIMRUNTIME =~ ' '
  19. if &sh =~ '\<cmd'
  20. let cmd = '""' . $VIMRUNTIME . '\diff"'
  21. let eq = '"'
  22. else
  23. let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
  24. endif
  25. else
  26. let cmd = $VIMRUNTIME . '\diff'
  27. endif
  28. silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
  29. endfunction
  30. set guifont=Courier\ 10\ Pitch\ Regular\ 15
  31. set nu
  32. set lines=35 columns=118
  33. " An example for a vimrc file.
  34. "
  35. " Maintainer: Bram Moolenaar <Bram@vim.org>
  36. " Last change: 2002 Sep 19
  37. "
  38. " To use it, copy it to
  39. " for Unix and OS/2: ~/.vimrc
  40. " for Amiga: s:.vimrc
  41. " for MS-DOS and Win32: $VIM\_vimrc
  42. " for OpenVMS: sys$login:.vimrc
  43. " When started as "evim", evim.vim will already have done these settings.
  44. if v:progname =~? "evim"
  45. finish
  46. endif
  47. " Use Vim settings, rather then Vi settings (much better!).
  48. " This must be first, because it changes other options as a side effect.
  49. set nocompatible
  50. " allow backspacing over everything in insert mode
  51. set backspace=indent,eol,start
  52. if has("vms")
  53. set nobackup " do not keep a backup file, use versions instead
  54. else
  55. set backup " keep a backup file
  56. endif
  57. set history=50 " keep 50 lines of command line history
  58. set ruler " show the cursor position all the time
  59. set showcmd " display incomplete commands
  60. set incsearch " do incremental searching
  61. " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
  62. " let &guioptions = substitute(&guioptions, "t", "", "g")
  63. " Don't use Ex mode, use Q for formatting
  64. map Q gq
  65. " This is an alternative that also works in block mode, but the deleted
  66. " text is lost and it only works for putting the current register.
  67. "vnoremap p "_dp
  68. " Switch syntax highlighting on, when the terminal has colors
  69. " Also switch on highlighting the last used search pattern.
  70. if &t_Co > 2 || has("gui_running")
  71. syntax on
  72. set hlsearch
  73. endif
  74. " Only do this part when compiled with support for autocommands.
  75. if has("autocmd")
  76. " Enable file type detection.
  77. " Use the default filetype settings, so that mail gets 'tw' set to 72,
  78. " 'cindent' is on in C files, etc.
  79. " Also load indent files, to automatically do language-dependent indenting.
  80. filetype plugin indent on
  81. " Put these in an autocmd group, so that we can delete them easily.
  82. augroup vimrcEx
  83. au!
  84. " For all text files set 'textwidth' to 78 characters.
  85. autocmd FileType text setlocal textwidth=78
  86. " When editing a file, always jump to the last known cursor position.
  87. " Don't do it when the position is invalid or when inside an event handler
  88. " (happens when dropping a file on gvim).
  89. autocmd BufReadPost *
  90. \ if line("'\"") > 0 && line("'\"") <= line("$") |
  91. \ exe "normal g`\"" |
  92. \ endif
  93. augroup END
  94. else
  95. set autoindent " always set autoindenting on
  96. endif " has("autocmd")
  97. set autoindent
  98. set sw=4
  99. set tabstop=4
  100. set noexpandtab
  101. set shiftwidth=4
  102. set list
  103. abbr deb #define DEBUG cerr << "Call out: " << __func__ << "\t" << "Line: " << __LINE__ << "\t :"
  104. set listchars=tab:>\
  105. abbr btf !astyle --style=ansi --indent=force-tab -c %
  106. colo zellner
  107. abbr inc #include<bits/stdc++.h>
  108. abbr rep #define repeat(a,b,c,g) for (int a=b,abck=(g>=0?1:-1);abck*(a)<=abck*(c);a+=g)
  109. abbr usi using namespace std;
  110. abbr frin freopen(".in","r",stdin);
  111. abbr frout freopen(".out","w",stdout);
  112. abbr fc fclose(stdin);fclose(stdout);
  113. abbr sc scanf
  114. abbr pr printf
  115. abbr ll long long
  116. " %F 完整文件路径名
  117. " %m 当前缓冲被修改标记
  118. " %m 当前缓冲只读标记
  119. " %h 帮助缓冲标记
  120. " %w 预览缓冲标记
  121. " %Y 文件类型
  122. " %b ASCII值
  123. " %B 十六进制值
  124. " %l 行数
  125. " %v 列数
  126. " %p 当前行数占总行数的的百分比
  127. " %L 总行数
  128. " %{...} 评估表达式的值,并用值代替
  129. " %{"[fenc=".(&fenc==""?&enc:&fenc).((exists("+bomb") && &bomb)?"+":"")."]"} 显示文件编码
  130. " %{&ff} 显示文件类型
  131. " 设置 laststatus = 0 ,不显式状态行
  132. " 设置 laststatus = 1 ,仅当窗口多于
  133. "------------------------------------------------------------------------------
  134. " < 判断操作系统是否是 Windows 还是 Linux >
  135. "------------------------------------------------------------------------------
  136. if(has("win32") || has("win64") || has("win95") || has("win16"))
  137. let g:iswindows = 1
  138. else
  139. let g:iswindows = 0
  140. endif
  141. "------------------------------------------------------------------------------
  142. " < 判断是终端还是 Gvim >
  143. "------------------------------------------------------------------------------
  144. if has("gui_running")
  145. let g:isGUI = 1
  146. else
  147. let g:isGUI = 0
  148. endif
  149. set cursorcolumn
  150. set cursorline
  151. highlight CursorLine cterm=NONE ctermbg=lightgrey guibg=NONE guifg=NONE
  152. highlight CursorColumn cterm=NONE ctermbg=lightgrey guibg=NONE guifg=NONE
  153. "------------------------------------------------------------------------------
  154. " < 编译、连接、运行配置 >
  155. "------------------------------------------------------------------------------
  156. " F9 一键保存、编译、连接存并运行
  157. map <F9> :call Run()<CR>
  158. imap <F9> <ESC>:call Run()<CR>
  159. " Ctrl + F9 一键保存并编译
  160. map <c-F9> :call Compile()<CR>
  161. imap <c-F9> <ESC>:call Compile()<CR>
  162. " Ctrl + F10 一键保存并连接
  163. map <c-F10> :call Link()<CR>
  164. imap <c-F10> <ESC>:call Link()<CR>
  165. let s:LastShellReturn_C = 0
  166. let s:LastShellReturn_L = 0
  167. let s:ShowWarning = 1
  168. let s:Obj_Extension = '.o'
  169. let s:Exe_Extension = '.exe'
  170. let s:Sou_Error = 0
  171. let s:windows_CFlags = 'gcc\ -fexec-charset=gbk\ -g\ -O0\ -c\ %\ -Wl,--stack=size -o\ %<.o'
  172. let s:linux_CFlags = 'gcc\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'
  173. let s:windows_CPPFlags = 'g++\ -std=c++11\ -fexec-charset=gbk\ -g\ -Wl,--stack=16777216\ -O0\ -c\ %\ -o\ %<.o'
  174. let s:linux_CPPFlags = 'g++\ -std=c++11\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'
  175. func! Compile()
  176. exe ":ccl"
  177. exe ":update"
  178. if expand("%:e") == "c" || expand("%:e") == "cpp" || expand("%:e") == "cxx"
  179. let s:Sou_Error = 0
  180. let s:LastShellReturn_C = 0
  181. let Sou = expand("%:p")
  182. let Obj = expand("%:p:r").s:Obj_Extension
  183. let Obj_Name = expand("%:p:t:r").s:Obj_Extension
  184. let v:statusmsg = ''
  185. if !filereadable(Obj) || (filereadable(Obj) && (getftime(Obj) < getftime(Sou)))
  186. redraw!
  187. if expand("%:e") == "c"
  188. if g:iswindows
  189. exe ":setlocal makeprg=".s:windows_CFlags
  190. else
  191. exe ":setlocal makeprg=".s:linux_CFlags
  192. endif
  193. echohl WarningMsg | echo " compiling..."
  194. silent make
  195. elseif expand("%:e") == "cpp" || expand("%:e") == "cxx"
  196. if g:iswindows
  197. exe ":setlocal makeprg=".s:windows_CPPFlags
  198. else
  199. exe ":setlocal makeprg=".s:linux_CPPFlags
  200. endif
  201. echohl WarningMsg | echo " compiling..."
  202. silent make
  203. endif
  204. redraw!
  205. if v:shell_error != 0
  206. let s:LastShellReturn_C = v:shell_error
  207. endif
  208. if g:iswindows
  209. if s:LastShellReturn_C != 0
  210. exe ":bo cope"
  211. echohl WarningMsg | echo " compilation failed"
  212. else
  213. if s:ShowWarning
  214. exe ":bo cw"
  215. endif
  216. echohl WarningMsg | echo " compilation successful"
  217. endif
  218. else
  219. if empty(v:statusmsg)
  220. echohl WarningMsg | echo " compilation successful"
  221. else
  222. exe ":bo cope"
  223. endif
  224. endif
  225. else
  226. echohl WarningMsg | echo ""Obj_Name"is up to date"
  227. endif
  228. else
  229. let s:Sou_Error = 1
  230. echohl WarningMsg | echo " please choose the correct source file"
  231. endif
  232. exe ":setlocal makeprg=make"
  233. endfunc
  234. func! Link()
  235. call Compile()
  236. if s:Sou_Error || s:LastShellReturn_C != 0
  237. return
  238. endif
  239. let s:LastShellReturn_L = 0
  240. let Sou = expand("%:p")
  241. let Obj = expand("%:p:r").s:Obj_Extension
  242. if g:iswindows
  243. let Exe = expand("%:p:r").s:Exe_Extension
  244. let Exe_Name = expand("%:p:t:r").s:Exe_Extension
  245. else
  246. let Exe = expand("%:p:r")
  247. let Exe_Name = expand("%:p:t:r")
  248. endif
  249. let v:statusmsg = ''
  250. if filereadable(Obj) && (getftime(Obj) >= getftime(Sou))
  251. redraw!
  252. if !executable(Exe) || (executable(Exe) && getftime(Exe) < getftime(Obj))
  253. if expand("%:e") == "c"
  254. setlocal makeprg=gcc\ -o\ %<\ %<.o
  255. echohl WarningMsg | echo " linking..."
  256. silent make
  257. elseif expand("%:e") == "cpp" || expand("%:e") == "cxx"
  258. setlocal makeprg=g++\ -o\ %<\ %<.o
  259. echohl WarningMsg | echo " linking..."
  260. silent make
  261. endif
  262. redraw!
  263. if v:shell_error != 0
  264. let s:LastShellReturn_L = v:shell_error
  265. endif
  266. if g:iswindows
  267. if s:LastShellReturn_L != 0
  268. exe ":bo cope"
  269. echohl WarningMsg | echo " linking failed"
  270. else
  271. if s:ShowWarning
  272. exe ":bo cw"
  273. endif
  274. echohl WarningMsg | echo " linking successful"
  275. endif
  276. else
  277. if empty(v:statusmsg)
  278. echohl WarningMsg | echo " linking successful"
  279. else
  280. exe ":bo cope"
  281. endif
  282. endif
  283. else
  284. echohl WarningMsg | echo ""Exe_Name"is up to date"
  285. endif
  286. endif
  287. setlocal makeprg=make
  288. endfunc
  289. func! Run()
  290. let s:ShowWarning = 0
  291. call Link()
  292. let s:ShowWarning = 1
  293. if s:Sou_Error || s:LastShellReturn_C != 0 || s:LastShellReturn_L != 0
  294. return
  295. endif
  296. let Sou = expand("%:p")
  297. let Obj = expand("%:p:r").s:Obj_Extension
  298. if g:iswindows
  299. let Exe = expand("%:p:r").s:Exe_Extension
  300. else
  301. let Exe = expand("%:p:r")
  302. endif
  303. if executable(Exe) && getftime(Exe) >= getftime(Obj) && getftime(Obj) >= getftime(Sou)
  304. redraw!
  305. echohl WarningMsg | echo " running..."
  306. if g:iswindows
  307. exe ":!%<.exe"
  308. else
  309. if g:isGUI
  310. exe ":!gnome-terminal -e ./%<"
  311. else
  312. exe ":!./%<"
  313. endif
  314. endif
  315. redraw!
  316. echohl WarningMsg | echo " running finish"
  317. endif
  318. endfunc

_vimrc的更多相关文章

  1. 在_vimrc中 set noexpandtab python 不起效果

    我ctm,今天配置不让tab转为空格,在_vimrc中set noexpandtab 不起效果. set ts=4也不起效果. 但是在命令行中其效果. 我都不知道咋办了. 问人说我有可能使用的不是那个 ...

  2. VIM中文乱码(_vimrc配置文件备份)

    _vimrc在用户目录下: set fileencodings=ucs-bom,utf-,cp936,gb18030,big5,euc-jp,euc-kr,latin1 set encoding=ut ...

  3. 我的_vimrc文件

    """"""""""""""""&quo ...

  4. _vimrc默认配置

    "不使用兼容vi的模式set nocompatible source $VIMRUNTIME/vimrc_example.vimsource $VIMRUNTIME/mswin.vimbeh ...

  5. _vimrc 的配置

    windows set nocompatible set guifont=Consolas:h17 color molokai set backspace=2 set sts=4 set ts=4 s ...

  6. Windows 下vim的配置文件_vimrc

    set nocompatible source $VIMRUNTIME/vimrc_example.vim source $VIMRUNTIME/mswin.vim behave mswin set ...

  7. _vimrc(VimScript脚本语言学习)

    Windows下 syntax on "高亮 "缩进 set cindent "set cin set smartindent "set si set auto ...

  8. gvim编辑器_vimrc文件

    set nocompatiblesource $VIMRUNTIME/vimrc_example.vimsource $VIMRUNTIME/mswin.vimbehave mswin set dif ...

  9. _vimrc配置

    set nocompatible set encoding=utf8 set guioptions-=T set number set guifont=consolas:h12 source $VIM ...

随机推荐

  1. String,StringBuffer,StringBulider 三者的区别

    1.String 是字符串常量,StringBuffer 和StringBuilder 是字符串变量. 2.运行速度 StringBuilder > StringBuffer > Stri ...

  2. Go语言中byte类型和rune类型(五)

    本篇内容本来准备在上一篇写的,想了想还是拆开写. go语言中字符串需要使用用双引号,而单引号用来表示单个的字符,字符也是组成字符串的元素.go语言的字符有两种: uint8类型,或者叫 byte 型, ...

  3. mysql 官网下载太慢了,来这里!!!

    RT.去官网下载mysql简直是折磨,太慢了!!! 但我还是坚持住了,下载下来了,我自己下载的是 MAC 5.7.27版本,网盘分享下,有需要的自提吧: 链接:https://pan.baidu.co ...

  4. 【6.12校内test】T2 子集

    这道题大概是这三道题里最简单的啦 但这阻止不了我废的脚步 [问题描述] 对于 n=4 时,对应的集合 s={4,3,2,1},他的非空子集有 15 个依次如下: {1} {2} {1,2} {3} { ...

  5. python中判断字典中是否存在某个键

    python3 中采用 in 方法 #判断字典中某个键是否存在 arr = {"int":"整数","float":"浮点&quo ...

  6. Select 和Alert

    Select 和Alert使用前都必须先导入 from selenium.webdriver.common.alert import Alert from selenium.webdriver.sup ...

  7. 优化 Karatsuba 乘法(老物)

    虽然写好了我自己用的a*启发函数但还是有些不尽人意,如果通过数学分析确定不出问题可以工作了的话应该就会发出来了 // Karatsuba 递归式距离推导 // h(x) = f(x) * g(x):/ ...

  8. 深入Spring Boot:那些注入不了的 Spring 占位符 ( ${} 表达式 )

    Spring里的占位符 spring里的占位符通常表现的形式是: 1 2 3 <bean id="dataSource" destroy-method="close ...

  9. linux命令详解——ln

    ln是linux中又一个非常重要命令,它的功能是为某一个文件在另外一个位置建立一个同不的链接,这个命令最常用的参数是-s,具体用法是:ln -s 源文件 目标文件. 当我们需要在不同的目录,用到相同的 ...

  10. ARM系统时钟初始化

    2440时钟体系,12MHz的晶振 6410时钟体系,12MHz的晶振 210时钟体系,24MHz晶振 时钟初始化:1.设置locktime 2.设置分频系数 4.设置CPU到异步工作模式 3.设置f ...