vimrc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. " Vundle plugin manager
  2. set nocompatible
  3. filetype off
  4. set rtp+=~/.vim/bundle/Vundle.vim
  5. call vundle#begin()
  6. Plugin 'VundleVim/Vundle.vim'
  7. call vundle#end()
  8. " Make hard tab look like 4 spaces tabs
  9. set shiftwidth=4
  10. set tabstop=4
  11. " When started as "evim", evim.vim will already have done these settings.
  12. if v:progname =~? "evim"
  13. finish
  14. endif
  15. " Use Vim settings, rather than Vi settings (much better!).
  16. " This must be first, because it changes other options as a side effect.
  17. " Avoid side effects when it was already reset.
  18. if &compatible
  19. set nocompatible
  20. endif
  21. " When the +eval feature is missing, the set command above will be skipped.
  22. " Use a trick to reset compatible only when the +eval feature is missing.
  23. silent! while 0
  24. set nocompatible
  25. silent! endwhile
  26. " Allow backspacing over everything in insert mode.
  27. set backspace=indent,eol,start
  28. set history=200
  29. set ruler
  30. set showcmd " display incomplete commands
  31. set wildmenu " display completion matches in a status line
  32. set ttimeout " time out for key codes
  33. set ttimeoutlen=100 " wait up to 100ms after Esc for special key
  34. " Show @@@ in the last line if it is truncated.
  35. set display=truncate
  36. " Show a few lines of context around the cursor. Note that this makes the
  37. " text scroll if you mouse-click near the start or end of the window.
  38. set scrolloff=5
  39. " Do incremental searching when it's possible to timeout.
  40. if has('reltime')
  41. set incsearch
  42. endif
  43. " Do not recognize octal numbers for Ctrl-A and Ctrl-X
  44. set nrformats-=octal
  45. " Don't use Ex mode, use Q for formatting.
  46. " Revert with ":unmap Q".
  47. map Q gq
  48. " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
  49. " so that you can undo CTRL-U after inserting a line break.
  50. " Revert with ":iunmap <C-U>".
  51. inoremap <C-U> <C-G>u<C-U>
  52. " Switch syntax highlighting on when available
  53. if &t_Co > 2 || has("gui_running")
  54. " Revert with ":syntax off".
  55. syntax on
  56. " I like highlighting strings inside C comments.
  57. " Revert with ":unlet c_comment_strings".
  58. let c_comment_strings=1
  59. endif
  60. " Only do this part when compiled with support for autocommands.
  61. if has("autocmd")
  62. " Enable file type detection.
  63. " Use the default filetype settings, so that mail gets 'tw' set to 72,
  64. " 'cindent' is on in C files, etc.
  65. " Also load indent files, to automatically do language-dependent indenting.
  66. " Revert with ":filetype off".
  67. filetype plugin indent on
  68. " Put these in an autocmd group, so that you can revert them with:
  69. " ":augroup vimStartup | au! | augroup END"
  70. augroup vimrcEx
  71. au!
  72. " When editing a file, always jump to the last known cursor position.
  73. " Don't do it when the position is invalid, when inside an event handler
  74. " (happens when dropping a file on gvim) and for a commit message (it's
  75. " likely a different one than last time).
  76. autocmd BufReadPost *
  77. \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
  78. \ | exe "normal! g`\""
  79. \ | endif
  80. " For all text files set 'textwidth' to 78 characters.
  81. autocmd FileType text setlocal textwidth=78
  82. augroup END
  83. else
  84. set autoindent " always set autoindenting on
  85. endif " has("autocmd")
  86. " Convenient command to see the difference between the current buffer and the
  87. " file it was loaded from, thus the changes you made.
  88. " Only define it when not defined already.
  89. " Revert with: ":delcommand DiffOrig".
  90. if !exists(":DiffOrig")
  91. command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
  92. \ | wincmd p | diffthis
  93. endif
  94. if has('langmap') && exists('+langremap')
  95. " Prevent that the langmap option applies to characters that result from a
  96. " mapping. If set (default), this may break plugins (but it's backward
  97. " compatible).
  98. set nolangremap
  99. endif
  100. set nobackup " do not keep a backup file, use versions instead
  101. if has('persistent_undo')
  102. set undofile " keep an undo file (undo changes after closing)
  103. set undodir=/tmp/
  104. endif
  105. " Add optional packages.
  106. "
  107. " The matchit plugin makes the % command work better, but it is not backwards
  108. " compatible.
  109. " The ! means the package won't be loaded right away but when plugins are
  110. " loaded during initialization.
  111. if has('syntax') && has('eval')
  112. packadd! matchit
  113. endif