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
  8. autocmd! bufwritepost .vimrc source $MYVIMRC
  9. """"""""
  10. "" Tabbing
  11. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  12. set tabstop=4 "actual tab presses
  13. set shiftwidth=4 "for autoindent
  14. set expandtab "change to single spaces
  15. set smarttab
  16. set autoindent "use last line to set next indent
  17. set smartindent "guess harder, based on C-like language
  18. " set wrap "wrap lines of text
  19. """"""""
  20. "" UI - Colours
  21. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  22. syntax on
  23. colorscheme desert
  24. set colorcolumn=80
  25. hi Folded ctermfg=darkred "set colour for folded lines
  26. """"""""
  27. "" UI - Numbering
  28. """"""""""""""""""""""""""""""""""""""""""""""""""""""""
  29. set number "show line numbers
  30. set relativenumber "current line always 0 (requires 7.3 and up)
  31. set ruler "show row,col count in status line
  32. """"""""
  33. "" UI - Code Folding
  34. """"""""""""""""""""""""""""""""""""""""""""""""""""""""
  35. set foldmethod=indent
  36. set foldlevel=1
  37. set foldtext=MyFoldText()
  38. function! MyFoldText()
  39. let line = getline(v:foldstart)
  40. let indent = indent(v:foldstart)
  41. let indentOnly = strpart(line, 0, indent-1)
  42. let linecount = v:foldend+1 - v:foldstart
  43. let plural = ""
  44. if linecount != 1
  45. let plural = "s"
  46. endif
  47. let foldtext = '+'.indentOnly.'... ('.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-