Chinaunix首页 | 论坛 | 博客
  • 博客访问: 44860
  • 博文数量: 7
  • 博客积分: 153
  • 博客等级: 入伍新兵
  • 技术积分: 100
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-22 00:28
文章分类

全部博文(7)

文章存档

2011年(7)

我的朋友

分类: LINUX

2011-11-02 08:35:09

  1. 忙活了半天,发到博客当个备份



  2. "改变主目录
  3. lcd g:\python
  4. "关闭vi兼容模式
  5. "set nocompatible
  6. "系统默认配置BEGIN
  7. source $VIMRUNTIME/vimrc_example.vim
  8. source $VIMRUNTIME/mswin.vim
  9. behave mswin
  10. set diffexpr=MyDiff()
  11. function MyDiff()
  12. let opt = '-a --binary '
  13. if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  14. if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  15. let arg1 = v:fname_in
  16. if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  17. let arg2 = v:fname_new
  18. if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  19. let arg3 = v:fname_out
  20. if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  21. let eq = ''
  22. if $VIMRUNTIME =~ ' '
  23. if &sh =~ '\
  24. let cmd = '""' . $VIMRUNTIME . '\diff"'
  25. let eq = '"'
  26. else
  27. let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
  28. endif
  29. else
  30. let cmd = $VIMRUNTIME . '\diff'
  31. endif
  32. silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
  33. endfunction
  34. """"""""""""""""""""""END""""""""""""""""""""""""""
  35. """""""""""""""""""自定义""""""""""""""""""""""""
  36. "配色方案
  37. colorscheme desert
  38. "设置语法高亮
  39. syntax on
  40. "启用行号
  41. set nu
  42. "启用鼠标
  43. set mouse=a
  44. "设定tab长度
  45. set tabstop=4
  46. "设定<<和>>命令移动时的宽度
  47. set shiftwidth=4
  48. "输入搜索内容时就显示搜索结果
  49. set incsearch
  50. "搜索时高亮显示被找到的文本
  51. set hlsearch
  52. "搜索时忽略大小写,但在有一个或以上大写字母时仍保持对大小写敏感
  53. set ignorecase smartcase
  54. "禁止在搜索到文件两端时重新搜索
  55. set nowrapscan
  56. "覆盖文件时不备份
  57. set nobackup
  58. "自动切换目录为当前文件所在的目录
  59. set autochdir
  60. "启用自动缩进,并设置自动缩进的宽度为4
  61. set autoindent shiftwidth=4
  62. "为C程序提供自动缩进
  63. set smartindent
  64. "使用C风格的缩进方案
  65. set cindent
  66. "显示制表位(ctrl+i)和 行尾标志($)
  67. "set list
  68. "侦测文件类型
  69. filetype on
  70. "载入文件类型插件
  71. filetype plugin on
  72. "为特定文件类型载入相关缩进文件
  73. filetype indent on
  74. "显示所用的编码(取决于“LANG环境变量”)
  75. "set encoding=utf-8
  76. "vim自动判断文件的编 码时尝试的顺序
  77. "set fileencodings=utf-8,cp936,big5,euc-jp,euc-kr,latin1,ucs-bom
  78. "让汉字以2个宽度显示
  79. set ambiwidth=double
  80. "设置帮助的语言为中文
  81. set helplang=cn
  82. "输出到客户终端(Term)采用的编码类型
  83. set termencoding=utf-8
  84. "与windows共享剪贴板
  85. set clipboard+=unnamed
  86. "状态行显示的内容
  87. set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
  88. "总是现实状态行
  89. set laststatus=2
  90. "开始折叠
  91. set foldenable
  92. "设置语法折叠
  93. set foldmethod=syntax
  94. "设置折叠区域的宽度
  95. set foldcolumn=1
  96. "设置折叠层数
  97. setlocal foldlevel=1
  98. "设置为自动关闭折叠
  99. set foldclose=all
  100. """""""""""""""""""""快捷键定义"""""""""""""""""""""""
  101. "用空格键来开关折叠
  102. nnoremap @=((foldclosed(line('.')) <0)?'zc':'zo')
  103. "运行程序
  104. map :call CompileRun()
  105. "添加文件说明
  106. map :silent call SetTitle()
  107. "t 打开TagList窗口,窗口在右边
  108. nmap t :TlistToggle
  109. """""""""""""""""""""自定义函数"""""""""""""""""""""""
  110. "运行程序
  111. func CompileRun()
  112. exec "w!"
  113. "C程序
  114. if &filetype == 'c'
  115. exec "!gcc % -g "
  116. exec "!a.exe"
  117. "C++
  118. elseif &filetype == 'cpp'
  119. exec "!g++ % -g "
  120. exec "!a.exe"
  121. "python
  122. elseif &filetype == 'python'
  123. exec "!python %"
  124. "bash
  125. elseif &filetype == 'sh'
  126. exec "!bash %"
  127. endif
  128. endfunc
  129. "定义函数SetTitle,自动插入文件头
  130. func SetTitle()
  131. ".sh或着python文件
  132. if &filetype == 'sh'||&filetype == 'python'
  133. call setline(1, "\#========================================================================")
  134. call append(line("."), "\# Author: Esperantor")
  135. call append(line(".")+1, "\# Email: esperantor@163.com")
  136. call append(line(".")+2, "\# File Name: ".expand("%"))
  137. call append(line(".")+3, "\# Description: ")
  138. call append(line(".")+4, "\# ")
  139. call append(line(".")+5, "\# Edit History: ")
  140. call append(line(".")+6, "\# ".strftime("%Y-%m-%d")." File created.")
  141. call append(line(".")+7, "\#========================================================================")
  142. call append(line(".")+8, "")
  143. "其它程序文件
  144. else
  145. call setline(1, "/**")
  146. call append(line("."), "=========================================================================")
  147. call append(line(".")+1, " Author: Esperantor")
  148. call append(line(".")+2, " Email: esperantor@163.com")
  149. call append(line(".")+3, " File Name: ".expand("%"))
  150. call append(line(".")+4, " Description: ")
  151. call append(line(".")+5, " ")
  152. call append(line(".")+6, " Edit History: ")
  153. call append(line(".")+7, " ".strftime("%Y-%m-%d")." File created.")
  154. call append(line(".")+8, "=========================================================================")
  155. call append(line(".")+9, "**/")
  156. call append(line(".")+10, "")
  157. endif
  158. "如果为sh文件,添加相应的头
  159. if &filetype == 'sh'
  160. call append(0, "\#!/bin/bash")
  161. "如果为python文件,添加相应的头和编码设定
  162. elseif &filetype == 'python'
  163. call append(0, "\#!/usr/bin/python")
  164. call append(1, "\# -*- coding: utf-8 -*-")
  165. endif
  166. endfunc
  167. """"""""""""""""""""""""""""插件配置""""""""""""""""""""""""""""
  168. "Taglist
  169. let Tlist_Show_One_File=1
  170. let Tlist_Exit_OnlyWindow=1
  171. "WinManager
  172. let g:winManagerWindowLayout='FileExplorer'
  173. nmap wm :WMToggle
  174. "MiniBufExplorer
  175. let g:miniBufExplMapCTabSwitchBufs = 1

阅读(1316) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:模式空间和保留空间及其几个应用

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