vimrc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. " An example for a vimrc file, forked from the original provided by Bram.
  2. "
  3. " Maintainer: Klaus Zimmermann <https://quitter.se/kzimmermann>
  4. " Original Author: Bram Moolenaar <Bram@vim.org>
  5. "
  6. " To use it, copy it to
  7. " for Unix and OS/2: ~/.vimrc
  8. " for Amiga: s:.vimrc
  9. " for MS-DOS and Win32: $VIM\_vimrc
  10. " for OpenVMS: sys$login:.vimrc
  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. set nocompatible
  18. " allow backspacing over everything in insert mode
  19. set backspace=indent,eol,start
  20. "if has("vms")
  21. " set nobackup " do not keep a backup file, use versions instead
  22. "else
  23. " set nobackup " keep a backup file
  24. "endif
  25. set history=50 " keep 50 lines of command line history
  26. set ruler " show the cursor position all the time
  27. set showcmd " display incomplete commands
  28. set incsearch " do incremental searching
  29. "-------------------
  30. " kzimmermann's personal preferences go here:
  31. " Tabs are 4-characters wide, strictly composed of space characters.
  32. " My house, my rules
  33. set ts=4
  34. set expandtab
  35. set shiftwidth=4
  36. set ai
  37. " I now prefer to leave wrapping on to help me write extensive documentation
  38. " like Markdown and HTML with long lines.
  39. set wrap
  40. set linebreak
  41. set nobackup
  42. " GUI stuff, most for playing along with GVIM.
  43. set guifont=Monospace\ 12
  44. colorscheme elflord
  45. " Unicode is your friend, and using it is a good habit :)
  46. set fileencoding=UTF-8
  47. set encoding=UTF-8
  48. " preferences end.
  49. "-------------------
  50. " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
  51. " let &guioptions = substitute(&guioptions, "t", "", "g")
  52. " Don't use Ex mode, use Q for formatting
  53. map Q gq
  54. " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
  55. " so that you can undo CTRL-U after inserting a line break.
  56. inoremap <C-U> <C-G>u<C-U>
  57. " In many terminal emulators the mouse works just fine, thus enable it.
  58. if has('mouse')
  59. set mouse=a
  60. endif
  61. " Switch syntax highlighting on, when the terminal has colors
  62. " Also switch on highlighting the last used search pattern.
  63. if &t_Co > 2 || has("gui_running")
  64. syntax on
  65. set hlsearch
  66. endif
  67. " Only do this part when compiled with support for autocommands.
  68. if has("autocmd")
  69. " Enable file type detection.
  70. " Use the default filetype settings, so that mail gets 'tw' set to 72,
  71. " 'cindent' is on in C files, etc.
  72. " Also load indent files, to automatically do language-dependent indenting.
  73. "filetype plugin indent on
  74. " Put these in an autocmd group, so that we can delete them easily.
  75. augroup vimrcEx
  76. au!
  77. " For all text files set 'textwidth' to 78 characters.
  78. autocmd FileType text setlocal textwidth=78
  79. " When editing a file, always jump to the last known cursor position.
  80. " Don't do it when the position is invalid or when inside an event handler
  81. " (happens when dropping a file on gvim).
  82. " Also don't do it when the mark is in the first line, that is the default
  83. " position when opening a file.
  84. autocmd BufReadPost *
  85. \ if line("'\"") > 1 && line("'\"") <= line("$") |
  86. \ exe "normal! g`\"" |
  87. \ endif
  88. augroup END
  89. else
  90. set autoindent " always set autoindenting on
  91. endif " has("autocmd")
  92. " Convenient command to see the difference between the current buffer and the
  93. " file it was loaded from, thus the changes you made.
  94. " Only define it when not defined already.
  95. if !exists(":DiffOrig")
  96. command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
  97. \ | wincmd p | diffthis
  98. endif