vimrc 3.9 KB

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