vimrc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. """"""""
  2. "" General Behaviours
  3. """""""""""""""""""""""""""""""""""""""""""""""""""
  4. set nocompatible "Don't have to try to be compatible with old vi
  5. set autoread "Read a file if it's changed from outside of vim
  6. let mapleader = "," "Leader key lets you make more kinds of shortcuts!
  7. " Source the vimrc file after saving it (courtesy of vimcasts.org!)
  8. if has("autocmd")
  9. autocmd bufwritepost .vimrc source $MYVIMRC
  10. endif
  11. """"""""
  12. "" Tabbing
  13. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  14. set tabstop=4 "actual tab presses
  15. set shiftwidth=4 "for autoindent
  16. set expandtab "change to single spaces
  17. set smarttab
  18. set autoindent "use last line to set next indent
  19. set smartindent "guess harder, based on C-like language
  20. " set wrap "wrap lines of text
  21. """"""""
  22. "" UI - Colours
  23. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  24. syntax on
  25. colorscheme desert
  26. set colorcolumn=80
  27. hi Folded ctermfg=darkred
  28. """"""""
  29. "" UI - Numbering
  30. """"""""""""""""""""""""""""""""""""""""""""""""""""""""
  31. set number "show line numbers
  32. set relativenumber "current line always 0 (requires 7.3 and up)
  33. set ruler "show row,col count in status line
  34. """"""""
  35. "" UI - Code Folding
  36. """"""""""""""""""""""""""""""""""""""""""""""""""""""""
  37. set foldmethod=indent
  38. set foldlevel=1
  39. set foldtext=MyFoldText()
  40. function! MyFoldText()
  41. let line = getline(v:foldstart)
  42. let linecount = v:foldend+1 - v:foldstart
  43. let plural = ""
  44. if linecount != 1
  45. let plural = "s"
  46. endif
  47. let foldtext = '+'.line.'... ('.linecount.' More lines)'
  48. return foldtext
  49. endfunction
  50. """"""""
  51. "" UI - Search
  52. """"""""""""""""""""""""""""""""""""""""""""""""""""""""
  53. set hlsearch "make searches highlighted
  54. set incsearch "vim will search as you type!
  55. """"""""
  56. "" Shortcuts
  57. """"""""""""""""""""""""""""""""""""""""""""""""""""""""
  58. " More convenient escape
  59. imap ii <Esc>
  60. imap II <Esc>
  61. " Add extra lines up and down
  62. map <leader>j o<Esc>k
  63. map <leader>k O<Esc>j
  64. " window resizing
  65. noremap + <C-w>10+
  66. noremap - <C-w>10-