vimrc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. hi Folded ctermfg=darkred "set colour for folded lines
  25. if version >= 730
  26. set colorcolumn=80
  27. endif
  28. """"""""
  29. "" UI - Numbering
  30. """"""""""""""""""""""""""""""""""""""""""""""""""""""""
  31. set number "show line numbers
  32. set ruler "show row,col count in status line
  33. if version >= 730
  34. set relativenumber "current line always 0 (requires 7.3 and up)
  35. endif
  36. """"""""
  37. "" UI - Code Folding
  38. """"""""""""""""""""""""""""""""""""""""""""""""""""""""
  39. set foldmethod=indent
  40. set foldlevel=1
  41. set foldtext=MyFoldText()
  42. function! MyFoldText()
  43. let line = getline(v:foldstart)
  44. let indent = indent(v:foldstart)
  45. let indentOnly = strpart(line, 0, indent-1)
  46. let linecount = v:foldend+1 - v:foldstart
  47. let plural = ""
  48. if linecount != 1
  49. let plural = "s"
  50. endif
  51. let foldtext = '+'.indentOnly.'... ('.linecount.' More lines)'
  52. return foldtext
  53. endfunction
  54. """"""""
  55. "" UI - Search
  56. """"""""""""""""""""""""""""""""""""""""""""""""""""""""
  57. set hlsearch "make searches highlighted
  58. set incsearch "vim will search as you type!
  59. """"""""
  60. "" Shortcuts
  61. """"""""""""""""""""""""""""""""""""""""""""""""""""""""
  62. " More convenient escape
  63. imap ii <Esc>
  64. imap II <Esc>
  65. " Add extra lines up and down
  66. map <leader>j o<Esc>k
  67. map <leader>k O<Esc>j
  68. " window resizing
  69. noremap + <C-w>10+
  70. noremap - <C-w>10-