Guest User

Untitled

a guest
May 23rd, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.55 KB | None | 0 0
  1. " .vimrc
  2. " Written by Matt Roper <matt@mattrope.com>
  3. "
  4. " Feel free to use any or all of this file in your own vimrc file.
  5.  
  6.  
  7. " Don't use vi compatibility; I want all the new features in Vim
  8. set nocompatible
  9.  
  10. " Version 6.0-specific stuff
  11. if version >= 600
  12. syntax enable
  13. filetype on
  14. filetype plugin on
  15. filetype indent on
  16. else
  17. syntax on
  18. endif
  19.  
  20. set number
  21.  
  22. " Low priority filename suffixes for filename completion {{{
  23. set suffixes-=.h " Don't give .h low priority
  24. set suffixes+=.aux
  25. set suffixes+=.log
  26. set wildignore+=*.dvi
  27. set suffixes+=.bak
  28. set suffixes+=~
  29. set suffixes+=.swp
  30. set suffixes+=.o
  31. set suffixes+=.class
  32. " }}}
  33.  
  34. set showfulltag " Get function usage help automatically
  35. set showcmd " Show current vim command in status bar
  36. set showmatch " Show matching parentheses/brackets
  37. set showmode " Show current vim mode
  38.  
  39. set background=dark
  40.  
  41. set bs=2 " allow backspacing over everything in insert mode
  42. set viminfo='20,\"50 " read/write a .viminfo file, don't store more
  43. " than 50 lines of registers
  44. set history=50 " keep 50 lines of command line history
  45. set ruler " show the cursor position all the time
  46. set nohlsearch " don't highlight search matches
  47. set selection=exclusive " don't include character under cursor in selection
  48. set incsearch " incremental (emacs-style) search
  49. set vb t_vb= " kill the beeps! (visible bell)
  50. set wildmenu " use a scrollable menu for filename completions
  51. "set ignorecase " case-insensitive searching
  52.  
  53. " Indentation / tab replacement stuff
  54. set shiftwidth=4 " > and < move block by 4 spaces in visual mode
  55. set sts=4
  56. set et " expand tabs to spaces
  57. set autoindent " always set autoindenting on
  58.  
  59. " Move text, but keep highlight
  60. vnoremap > ><CR>gv
  61. vnoremap < <<CR>gv
  62.  
  63. " Color Scheme (only if GUI running) {{{
  64. if has("gui_running")
  65. colorscheme evening
  66. endif
  67. " }}}
  68.  
  69. " Key mappings {{{
  70.  
  71. " Allow the . to execute once for each line in visual selection
  72. vnoremap . :normal .<CR>
  73.  
  74. " Make ' function behave like ` usually does and then change ` to replay
  75. " recorded macro a (as if @a was typed). In visual mode, ` (which now acts
  76. " like @a) should function on all selected lines.
  77. noremap ' `
  78. nnoremap ` @a
  79. vnoremap ` :normal @a<CR>
  80.  
  81. " Make tab perform keyword/tag completion if we're not following whitespace
  82. inoremap <tab> <c-r>=InsertTabWrapper()<cr>
  83.  
  84. " Make F7 spellcheck the buffer
  85. noremap <F7> <Esc>:call IspellCheck()<CR><Esc>
  86.  
  87. inoremap <F9> <Esc>:make<CR>
  88. inoremap <F10> <Esc>:cnext<CR>
  89. inoremap <F11> <Esc>:cprev<CR>
  90. noremap <F9> <Esc>:make<CR>
  91. noremap <F10> <Esc>:cnext<CR>
  92. noremap <F11> <Esc>:cprev<CR>
  93.  
  94. " Buffer Switching:
  95. " F2 = next buffer
  96. " F3 = previous buffer
  97. " F4 = kill buffer
  98. inoremap <F2> <Esc>:bn<CR>
  99. inoremap <F3> <Esc>:bp<CR>
  100. inoremap <F4> <Esc>:bd<CR>
  101. noremap <F2> <Esc>:bn<CR>
  102. noremap <F3> <Esc>:bp<CR>
  103. noremap <F4> <Esc>:bd<CR>
  104.  
  105. " Make p in Visual mode replace the selected text with the "" register.
  106. vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
  107.  
  108. " Key mappings }}}
  109.  
  110. " Autocommands {{{
  111. if has("autocmd")
  112.  
  113. " When vim is used in a console window, set the title bar to the
  114. " name of the buffer being editted.
  115. if !has("gui_running")
  116. auto BufEnter * let &titlestring="VIM - ".expand("%:p")
  117. endif
  118.  
  119. " In text and LaTeX files, always limit the width of text to 76
  120. " characters. Also perform logical wrapping/indenting.
  121. autocmd BufRead *.txt set tw=76 formatoptions=tcroqn2l
  122. autocmd BufRead *.tex set tw=76
  123.  
  124. " Programming settings {{{
  125. augroup prog
  126. au!
  127. au BufRead *.c,*.cc,*.cpp,*.h,*.java set formatoptions=croql cindent nowrap nofoldenable
  128. au BufEnter *.java map <C-Return> :w\|:!javac %<CR>
  129. au BufEnter *.c map <C-Return> :w\|:!gcc %<CR>
  130. au BufEnter *.cc,*.cpp map <C-Return> :w\|:!g++ %<CR>
  131. au BufLeave *.java,*.c,*.cc unmap <C-Return>
  132.  
  133. " Don't expand tabs to spaces in Makefiles
  134. au BufEnter [Mm]akefile* set noet
  135. au BufLeave [Mm]akefile* set et
  136.  
  137. " Set up folding for python
  138. au FileType python set nofoldenable foldmethod=indent
  139. augroup END
  140. " }}}
  141.  
  142. " Reread configuration of Vim if .vimrc is saved {{{
  143. augroup VimConfig
  144. au!
  145. autocmd BufWritePost ~/.vimrc so ~/.vimrc
  146. autocmd BufWritePost vimrc so ~/.vimrc
  147. augroup END
  148. " }}}
  149.  
  150.  
  151. " " C programming auto commands {{{
  152. " augroup cprog
  153. " au!
  154. "
  155. " " When starting to edit a file:
  156. " " For C and C++ files set formatting of comments and set C-indenting on.
  157. " " For other files switch it off.
  158. " " Don't change the order, it's important that the line with * comes first.
  159. " "autocmd FileType * set formatoptions=tcql nocindent comments&
  160. " "autocmd FileType c,cpp set formatoptions=croql comments=sr:/*,mb:*,el:*/,://
  161. "
  162. " " Automatic "folding" in C code. This is cool.
  163. " "if version >= 600
  164. " " "au FileType c set foldenable foldmethod=indent
  165. " " au FileType c,cpp set nofoldenable foldmethod=syntax
  166. " " au FileType c,cpp syn region Block start="{" end="}" transparent fold
  167. " " "au FileType c syn region Comment start="/\*" end="\*/" fold
  168. " "endif
  169. " augroup END
  170. " " }}}
  171.  
  172. endif " has("autocmd")
  173. " }}}
  174.  
  175. " Functions {{{
  176.  
  177. " IspellCheck() {{{
  178. function! IspellCheck()
  179. let l:tmpfile = tempname()
  180.  
  181. execute "normal:w!" . l:tmpfile . "\<CR>"
  182. if has("gui_running")
  183. execute "normal:!xterm -e ispell " . l:tmpfile . "\<CR>"
  184. else
  185. execute "normal:! ispell " . l:tmpfile . "\<CR>"
  186. endif
  187. execute "normal:%d\<CR>"
  188. execute "normal:r " . l:tmpfile . "\<CR>"
  189. execute "normal:1d\<CR>"
  190. endfunction
  191. " IspellCheck }}}
  192.  
  193. " InsertTabWrapper() {{{
  194. " Tab completion of tags/keywords if not at the beginning of the
  195. " line. Very slick.
  196. function! InsertTabWrapper()
  197. let col = col('.') - 1
  198. if !col || getline('.')[col - 1] !~ '\k'
  199. return "\<tab>"
  200. else
  201. return "\<c-p>"
  202. endif
  203. endfunction
  204. " InsertTabWrapper() }}}
  205.  
  206. " Functions }}}
  207.  
  208. " Settings for specific syntax files {{{
  209. let c_gnu=1
  210. let c_comment_strings=1
  211. let c_space_errors=1
  212.  
  213. "let perl_fold=1 " turn on perl folding capabilities
  214. " }}}
  215.  
  216.  
  217. " Modeline {{{
  218. " vim:set ts=4:
  219. " vim600:fdm=marker fdl=0 fdc=3 vb t_vb=:
  220. " }}}
Add Comment
Please, Sign In to add comment