我的vim配置文件


相對比較完美的配置方案
vim對新手來說配置還是相當的複雜,想要直接複製一個配置方案是一個錯誤的想法,最好的解決方法還是在初始版本的基礎上熟練各項操作後,按照自己的習慣,參考別人的配置方案--對於自己不熟悉的選項絕對不用(影響穩定性),最後綜合插件將vim打造成一個IDE
  1. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  2. " Stuff I have decided I don't like
  3. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  4. "set ignorecase -- turns out, I like case sensitivity 
  5. "set list " turns out, I don't like listchars -- show chars on end of line, whitespace, etc
  6. "autocmd GUIEnter * :simalt ~x -- having it auto maximize the screen is annoying
  7. "autocmd BufEnter * :lcd %:p:h -- switch to current dir (breaks some scripts)
  8. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  9. " General
  10. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  11. set nocompatible " get out of horrible vi-compatible mode
  12. filetype on " detect the type of file
  13. set history=1000 " How many lines of history to remember
  14. set cf " enable error files and error jumping
  15. set clipboard+=unnamed " turns out I do like is sharing windows clipboard
  16. set ffs=dos,unix,mac " support all three, in this order
  17. filetype plugin on " load filetype plugins
  18. set viminfo+=! " make sure it can save viminfo
  19. set isk+=_,$,@,%,#,- " none of these should be word dividers, so make them not be
  20. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  21. " Theme/Colors
  22. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  23. set background=dark  "we are using a dark background
  24. syntax on " syntax highlighting on
  25. "colorscheme matrix " my theme
  26. colorscheme robinhood " my theme
  27. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  28. " Files/Backups
  29. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  30. "set backup " make backup file
  31. "set backupdir=$VIM/vimfiles/backup " where to put backup file
  32. "set directory=$VIM/vimfiles/temp " directory is the directory for temp file
  33. "set makeef=error.err " When using make, where should it dump the file
  34. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  35. " Vim UI
  36. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  37. set lsp=0 " space it out a little more (easier to read)
  38. set wildmenu " turn on wild menu
  39. set ruler " Always show current positions along the bottom 
  40. set cmdheight=2 " the command bar is 2 high
  41. set number " turn on line numbers
  42. "set lz " do not redraw while running macros (much faster) (LazyRedraw)
  43. set hid " you can change buffer without saving
  44. set backspace=2 " make backspace work normal
  45. set whichwrap+=<,>,h,l  " backspace and cursor keys wrap to
  46. set mouse=a " use mouse everywhere
  47. set shortmess=atI " shortens messages to avoid 'press a key' prompt 
  48. set report=0 " tell us when anything is changed via :...
  49. set noerrorbells " don't make noise
  50. set wrap
  51. " make the splitters between windows be blank
  52. "set fillchars=vert:/ ,stl:/ ,stlnc:/ 
  53. set guifont=Bitstream/ Vera/ Sans/ Mono/ 15
  54. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  55. " Visual Cues
  56. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  57. set showmatch " show matching brackets
  58. set mat=5 " how many tenths of a second to blink matching brackets for
  59. set nohlsearch " do not highlight searched for phrases
  60. set incsearch " BUT do highlight as you type you search phrase
  61. set listchars=tab:/|/ ,trail:.,extends:>,precedes:<,eol:$ " what to show when I hit :set list
  62. set lines=80 " 80 lines tall
  63. set columns=160 " 160 cols wide
  64. set so=10 " Keep 10 lines (top/bottom) for scope
  65. set novisualbell " don't blink
  66. set noerrorbells " no noises
  67. set statusline=%F%m%r%h%w/ [FORMAT=%{&ff}]/ [TYPE=%Y]/ [ASCII=/%03.3b]/ [HEX=/%02.2B]/ [POS=%04l,%04v][%p%%]/ [LEN=%L]
  68. set laststatus=2 " always show the status line
  69. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  70. " Text Formatting/Layout
  71. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  72. set fo=tcrqn " See Help (complex)
  73. set ai " autoindent
  74. set si " smartindent 
  75. set cindent " do c-style indenting
  76. set tabstop=8 " tab spacing (settings below are just to unify it)
  77. set softtabstop=8 " unify
  78. set shiftwidth=8 " unify 
  79. set noexpandtab " real tabs please!
  80. set nowrap " do not wrap lines  
  81. set smarttab " use tabs at the start of a line, spaces elsewhere
  82. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  83. " Folding
  84. "    Enable folding, but by default make it act like folding is off, because folding is annoying in anything but a few rare cases
  85. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  86. set foldenable " Turn on folding
  87. set foldmethod=indent " Make folding indent sensitive
  88. set foldlevel=100 " Don't autofold anything (but I can still fold manually)
  89. set foldopen-=search " don't open folds when you search into them
  90. set foldopen-=undo " don't open folds when you undo stuff
  91. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  92. " File Explorer
  93. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  94. let g:explVertical=1 " should I split verticially
  95. let g:explWinSize=35 " width of 35 pixels
  96. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  97. " Win Manager
  98. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  99. let g:winManagerWidth=35 " How wide should it be( pixels)
  100. let g:winManagerWindowLayout = 'FileExplorer,TagsExplorer|BufExplorer' " What windows should it
  101. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  102. " CTags
  103. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  104. let Tlist_Ctags_Cmd = $VIM.'/ctags.exe' " Location of ctags
  105. let Tlist_Sort_Type = "name" " order by 
  106. let Tlist_Use_Right_Window = 1 " split to the right side of the screen
  107. let Tlist_Compart_Format = 1 " show small meny
  108. let Tlist_Exist_OnlyWindow = 1 " if you are the last, kill yourself
  109. let Tlist_File_Fold_Auto_Close = 0 " Do not close tags for other files
  110. let Tlist_Enable_Fold_Column = 0 " Do not show folding tree
  111. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  112. " Minibuf
  113. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  114. let g:miniBufExplTabWrap = 1 " make tabs show complete (no broken on two lines)
  115. let g:miniBufExplModSelTarget = 1
  116. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  117. " Matchit
  118. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  119. let b:match_ignorecase = 1
  120. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  121. " Custom Functions
  122. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  123. " Select range, then hit :SuperRetab($width) - by p0g and FallingCow
  124. function! SuperRetab(width) range
  125.     silent! exe a:firstline . ',' . a:lastline . 's//v%(^ *)@<= {'. a:width .'}//t/g'
  126. endfunction
  127. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  128. " Mappings
  129. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  130. map <right> <ESC>:MBEbn<RETURN> " right arrow (normal mode) switches buffers  (excluding minibuf)
  131. map <left> <ESC>:MBEbp<RETURN> " left arrow (normal mode) switches buffers (excluding minibuf) 
  132. map <up> <ESC>:Sex<RETURN><ESC><C-W><C-W> " up arrow (normal mode) brings up a file list
  133. map <down> <ESC>:Tlist<RETURN> " down arrow  (normal mode) brings up the tag list
  134. map <A-i> i <ESC>r " alt-i (normal mode) inserts a single char, and then switches back to normal
  135. map <F2> <ESC>ggVG:call SuperRetab()<left>
  136. map <F12> ggVGg? " encypt the file (toggle)
  137. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  138. " Autocommands
  139. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  140. "autocmd BufEnter * :syntax sync fromstart " ensure every file does syntax highlighting (full)
  141. "au BufNewFile,BufRead *.asp :set ft=aspjscript " all my .asp files ARE jscript
  142. "au BufNewFile,BufRead *.tpl :set ft=html " all my .tpl files ARE html
  143. "au BufNewFile,BufRead *.hta :set ft=html " all my .tpl files ARE html
  144. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  145. " Useful abbrevs
  146. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  147. iab xasp <%@language=jscript%><CR><%<CR><TAB><CR><BS>%><ESC><<O<TAB>
  148. iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr> 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章