Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 20th, 2012  |  syntax: None  |  size: 5.92 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. "
  2. " MisoF's .vimrc
  3. " version 2.2 2011-10-24
  4. "
  5.  
  6. " ======================================================================================================
  7. " For starters, some settings that should be default, but one never knows: {{{
  8. set nocompatible " we want new vim features whenever they are available
  9. set bs=2         " backspace should work as we expect it to
  10. set autoindent
  11. set history=50   " remember last 50 commands
  12. set ruler        " show cursor position in the bottom line
  13. syntax on        " turn on syntax highlighting if not available by default
  14. " }}}
  15. " ======================================================================================================
  16. " Small tweaks: my preferred indentation, colors, autowrite, status line etc.:  {{{
  17.  
  18. " currently I prefer indent step 4 and spaces -- tabs are evil and should be avoided
  19. set shiftwidth=4
  20. set expandtab
  21. set softtabstop=4
  22.  
  23. " by default, if I'm editing text, I want it to wrap
  24. set textwidth=100
  25.  
  26. " my terminal is dark, use an appropriate colorscheme
  27. set background=dark
  28. " use the following to force black background if necessary:
  29. " highlight Normal guibg=black guifg=white ctermbg=black ctermfg=white
  30.  
  31. " automatically save before each make/execute command
  32. set autowrite
  33.  
  34. " if I press <tab> in command line, show me all options if there is more than one
  35. set wildmenu
  36.  
  37. " y and d put stuff into system clipboard (so that other apps can see it)
  38. set clipboard=unnamed
  39.  
  40. " adjust timeout for mapped commands: 200 milliseconds should be enough for everyone
  41. set timeout
  42. set timeoutlen=200
  43.  
  44. " an alias to convert a file to html, using vim syntax highlighting
  45. command ConvertToHTML so $VIMRUNTIME/syntax/2html.vim
  46.  
  47. " text search settings
  48. set incsearch  " show the first match already while I type
  49. set ignorecase
  50. set smartcase  " only be case-sensitive if I use uppercase in my query
  51. set nohlsearch " I hate when half of the text lights up
  52.  
  53. " enough with the @@@s, show all you can if the last displayed line is too long
  54. set display+=lastline
  55. " show chars that cannot be displayed as <13> instead of ^M
  56. set display+=uhex
  57.  
  58. " status line: we want it at all times -- white on blue, with ASCII code of the current letter
  59. set statusline=%<%f%h%m%r%=char=%b=0x%B\ \ %l,%c%V\ %P
  60. set laststatus=2
  61. set highlight+=s:MyStatusLineHighlight
  62. highlight MyStatusLineHighlight ctermbg=darkblue ctermfg=white
  63.  
  64. " tab line: blue as well to fit the theme
  65. " (this is what appears instead of the status line when you use <tab> in command mode)
  66. highlight TabLine ctermbg=darkblue ctermfg=gray
  67. highlight TabLineSel ctermbg=darkblue ctermfg=yellow
  68. highlight TabLineFill ctermbg=darkblue ctermfg=darkblue
  69.  
  70. " }}}
  71. " ======================================================================================================
  72. " <Tab> at the end of a word should attempt to complete it using tokens from the current file: {{{
  73. function! My_Tab_Completion()
  74.     if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'
  75.         return "\<C-P>"
  76.     else
  77.         return "\<Tab>"
  78. endfunction
  79. inoremap <Tab> <C-R>=My_Tab_Completion()<CR>
  80. " }}}
  81. " ======================================================================================================
  82. " Specific settings for specific filetypes:  {{{
  83.  
  84. " usual policy: if there is a Makefile present, :mak calls make, otherwise we define a command to compile the filetype
  85.  
  86. " LaTeX
  87. function! TEXSET()
  88.   set makeprg=if\ \[\ -f\ \"Makefile\"\ \];then\ make\ $*;else\ if\ \[\ -f\ \"makefile\"\ \];then\ make\ $*;else\ pdfcslatex\ -file-line-error-style\ %;fi;fi
  89.   set errorformat=%f:%l:\ %m
  90. endfunction
  91.  
  92. " C/C++:
  93. function! CSET()
  94.   set makeprg=if\ \[\ -f\ \"Makefile\"\ \];then\ make\ $*;else\ if\ \[\ -f\ \"makefile\"\ \];then\ make\ $*;else\ gcc\ -O2\ -g\ -Wall\ -W\ -lm\ -o%.bin\ %;fi;fi
  95.   set errorformat=%f:%l:\ %m
  96.   set cindent
  97.   set tw=0
  98.   set nowrap
  99. endfunction
  100.  
  101. function! CPPSET()
  102.   set makeprg=if\ \[\ -f\ \"Makefile\"\ \];then\ make\ $*;else\ if\ \[\ -f\ \"makefile\"\ \];then\ make\ $*;else\ g++\ -O2\ -g\ -Wall\ -W\ -o%.bin\ %;fi;fi
  103.   set cindent
  104.   set tw=0
  105.   set nowrap
  106. endfunction
  107.  
  108. " Java
  109. function! JAVASET()
  110.   set makeprg=if\ \[\ -f\ \"Makefile\"\ \];then\ make\ $*;else\ if\ \[\ -f\ \"makefile\"\ \];then\ make\ $*;else\ javac\ -g\ %;fi;fi
  111.   set errorformat=%f:%l:\ %m
  112.   set cindent
  113.   set tw=0
  114.   set nowrap
  115. endfunction
  116.  
  117. " Pascal
  118. function! PPSET()
  119.   set makeprg=if\ \[\ -f\ \"Makefile\"\ \];then\ make\ $*;else\ if\ \[\ -f\ \"makefile\"\ \];then\ make\ $*;else\ fpc\ -g\ -O2\ -o\%.bin\ %;fi;fi
  120.   set errorformat=%f:%l:\ %m
  121.   set tw=0
  122.   set nowrap
  123. endfunction
  124.  
  125. " vim scripts
  126. function! VIMSET()
  127.   set tw=0
  128.   set nowrap
  129.   set comments+=b:\"
  130. endfunction
  131.  
  132. " Makefile
  133. function! MAKEFILESET()
  134.   set tw=0
  135.   set nowrap
  136.   " in a Makefile we need to use <Tab> to actually produce tabs
  137.   set noet
  138.   set sts=8
  139.   iunmap <Tab>
  140. endfunction
  141.  
  142. " HTML/PHP
  143. function! HTMLSET()
  144.   set tw=0
  145.   set nowrap
  146. endfunction
  147.  
  148. " Asymptote
  149. function! ASYSET()
  150.   runtime asy.vim " find this somewhere and place it into ~/.vim/ for syntax hl to work
  151.   set tw=0
  152.   set nowrap
  153.   set makeprg=asy\ -noV\ -fpdf\ %\ -o\ %.pdf
  154.   set errorformat=%f:\ %l.%c:\ %m
  155. endfunction
  156.  
  157. " Python
  158. function! PYSET()
  159.   set tw=0
  160.   set nowrap
  161. endfunction
  162.  
  163. " Asymptote does not get recognized by default, fix it
  164. augroup filetypedetect
  165. autocmd BufNewFile,BufRead *.asy setfiletype asy
  166. augroup END
  167. filetype plugin on
  168.  
  169. " Autocommands for all languages:
  170. autocmd FileType vim    call VIMSET()
  171. autocmd FileType c      call CSET()
  172. autocmd FileType C      call CPPSET()
  173. autocmd FileType cc     call CPPSET()
  174. autocmd FileType cpp    call CPPSET()
  175. autocmd FileType java   call JAVASET()
  176. autocmd FileType tex    call TEXSET()
  177. autocmd FileType pascal call PPSET()
  178. autocmd FileType make   call MAKEFILESET()
  179. autocmd FileType html   call HTMLSET()
  180. autocmd FileType php    call HTMLSET()
  181. autocmd FileType asy    call ASYSET()
  182. autocmd FileType python call PYSET()
  183.  
  184. " }}}
  185. " ======================================================================================================
  186.  
  187. " finally, tell the folds to fold on file open
  188. set fdm=marker
  189. set commentstring=\ \"\ %s