[关闭]
@coldxiangyu 2017-06-09T00:59:54.000000Z 字数 2112 阅读 1003

My vim _vimrc

Vim


个人vim配置,持续更新。

  1. source $VIMRUNTIME/vimrc_example.vim
  2. " An example for a vimrc file.
  3. "
  4. " Maintainer: Bram Moolenaar <Bram@vim.org>
  5. " Last change: 2016 Jul 28
  6. "
  7. " To use it, copy it to
  8. " for Unix and OS/2: ~/.vimrc
  9. " for Amiga: s:.vimrc
  10. " for MS-DOS and Win32: $VIM\_vimrc
  11. " for OpenVMS: sys$login:.vimrc
  12. " When started as "evim", evim.vim will already have done these settings.
  13. if v:progname =~? "evim"
  14. finish
  15. endif
  16. " Get the defaults that most users want.
  17. source $VIMRUNTIME/defaults.vim
  18. if has("vms")
  19. set nobackup " do not keep a backup file, use versions instead
  20. else
  21. set backup " keep a backup file (restore to previous version)
  22. if has('persistent_undo')
  23. set undofile " keep an undo file (undo changes after closing)
  24. endif
  25. endif
  26. if &t_Co > 2 || has("gui_running")
  27. " Switch on highlighting the last used search pattern.
  28. set hlsearch
  29. endif
  30. " Only do this part when compiled with support for autocommands.
  31. if has("autocmd")
  32. " Put these in an autocmd group, so that we can delete them easily.
  33. augroup vimrcEx
  34. au!
  35. " For all text files set 'textwidth' to 78 characters.
  36. autocmd FileType text setlocal textwidth=78
  37. augroup END
  38. else
  39. set autoindent " always set autoindenting on
  40. endif " has("autocmd")
  41. " Add optional packages.
  42. "
  43. " The matchit plugin makes the % command work better, but it is not backwards
  44. " compatible.
  45. if has('syntax') && has('eval')
  46. packadd matchit
  47. endif
  48. source $VIMRUNTIME/mswin.vim
  49. behave mswin
  50. "Toggle Menu and Toolbar
  51. set guioptions-=m
  52. set guioptions-=T
  53. set number
  54. set writebackup
  55. set noundofile
  56. set nobackup
  57. set noswapfile
  58. colo evening
  59. set fileencodings=ucs-bom,utf-8,utf-16,gbk,big5,gb18030,latin1
  60. map :if &guioptions =~# 'T'
  61. \set guioptions-=T
  62. \set guioptions-=m
  63. \else
  64. \set guioptions+=T
  65. \set guioptions+=m
  66. \endif
  67. set diffexpr=MyDiff()
  68. function MyDiff()
  69. let opt = '-a --binary '
  70. if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  71. if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  72. let arg1 = v:fname_in
  73. if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  74. let arg2 = v:fname_new
  75. if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  76. let arg3 = v:fname_out
  77. if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  78. if $VIMRUNTIME =~ ' '
  79. if &sh =~ '\<cmd'
  80. if empty(&shellxquote)
  81. let l:shxq_sav = ''
  82. set shellxquote&
  83. endif
  84. let cmd = '"' . $VIMRUNTIME . '\diff"'
  85. else
  86. let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
  87. endif
  88. else
  89. let cmd = $VIMRUNTIME . '\diff'
  90. endif
  91. silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  92. if exists('l:shxq_sav')
  93. let &shellxquote=l:shxq_sav
  94. endif
  95. endfunction
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注