You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 lines
4.0 KiB

  1. " Call pathogen if it's installed
  2. call pathogen#infect()
  3. """"
  4. " General Settings
  5. """"
  6. set history=500
  7. " File based settings and indentation
  8. filetype plugin on
  9. filetype indent on
  10. " Auto reload files
  11. set autoread
  12. " define a leader symbol
  13. let mapleader = ","
  14. let g:mapleader = ","
  15. " Fast saving
  16. nmap <leader>w :w!<cr>
  17. " :W sudo saves the file
  18. " Useful for avoiding permission-denied errors
  19. command W w !sudo tee % > /dev/null
  20. """"
  21. " VIM Interface Settings
  22. """"
  23. " set j/k to move by 7 lines
  24. set so=7
  25. " Enable the WiLd menu
  26. set wildmenu
  27. " Ignore compiled files
  28. set wildignore=*.o,*~,*.pyc
  29. set wildignore+=*/.git/*,*/.hg/*,*/.svn/*
  30. " Show the ruler
  31. set ruler
  32. " Show line numbers
  33. set number
  34. " Command bar height should be 2 rows
  35. set cmdheight=2
  36. " Hide buffers when they're abandoned
  37. set hid
  38. " Configure backspace
  39. set backspace=eol,start,indent
  40. set whichwrap+=<,>,h,l
  41. " Ingore case while searching
  42. set ignorecase
  43. " Be smart about case while searching
  44. set smartcase
  45. " Highlight results
  46. set hlsearch
  47. " Search more like modern browsers
  48. set incsearch
  49. " Avoid redrawing during macros
  50. set lazyredraw
  51. " For regular expressions
  52. set magic
  53. " Show matching brackets
  54. set showmatch
  55. set mat=2
  56. " Disable annoying sounds
  57. set noerrorbells
  58. set novisualbell
  59. set t_vb=
  60. set tm=500
  61. " Extra column on the left
  62. set foldcolumn=1
  63. """"
  64. " Colors and Fonts
  65. """"
  66. " Enable syntax highlighting
  67. syntax enable
  68. " Set the vim editor color scheme
  69. :color desert
  70. " Optimize colors for a dark terminal
  71. set background=dark
  72. " Default to a utf8 encoding
  73. set encoding=utf8
  74. " Unix will be the default file type
  75. set ffs=unix,dos,mac
  76. """"
  77. " Text, Tab, Indent
  78. """"
  79. " Expand Tabs
  80. set expandtab
  81. " Smart Tabs
  82. set smarttab
  83. " Tabs are 4 spaces
  84. set shiftwidth=4
  85. set tabstop=4
  86. set softtabstop=4
  87. " 500 character max per line
  88. set lbr
  89. set tw=500
  90. " Auto Indent, Smart Indent and Line Wrapping
  91. set ai
  92. set si
  93. set wrap
  94. """"
  95. " Movement, Tabs, Buffers, Windows
  96. """"
  97. " Prevent movement to the first char on the line
  98. set nostartofline
  99. " Quickly timeout on keycodes, but never on mappings
  100. set notimeout ttimeout ttimeoutlen=200
  101. " Long lines are break lines
  102. map j gj
  103. map k gk
  104. " Better movement between windows
  105. map <C-j> <C-W>j
  106. map <C-k> <C-W>k
  107. map <C-h> <C-W>h
  108. map <C-l> <C-W>l
  109. " Remap to arrows to navigate wrapped lines
  110. imap <silent> <Down> <C-o>gj
  111. imap <silent> <Up> <C-o>gk
  112. nmap <silent> <Down> gj
  113. nmap <silent> <Up> gk
  114. """"
  115. " Status Line
  116. """"
  117. " Show the status line
  118. set laststatus=2
  119. " Format for the status line
  120. set statusline=\ %{HasPaste()}
  121. set statusline+=%F "File
  122. set statusline+=%m%r%h "File mode/status
  123. set statusline+=\ %y "File type
  124. set statusline+=\ %w
  125. set statusline+=\ \ CWD:\ %r%{getcwd()}%h
  126. set statusline+==%= " left/right seperator
  127. set statusline+=Line:\ %l.%c/%L "line and column count
  128. set statusline+=\ %P "percentage of document
  129. " Set the statusline color based on the current mode
  130. au InsertEnter * call InsertStatusLineColor(v:insertmode)
  131. au InsertLeave * hi Statusline ctermfg=black ctermbg=white guifg=black guibg=white
  132. " Grey status line on first entrance
  133. hi Statusline ctermfg=black ctermbg=white guifg=black guibg=white
  134. """"
  135. " Spell Checking
  136. """"
  137. " Pressing ,ss will toggle spell checking
  138. map <leader>ss :setlocal spell!<cr>
  139. " Leader shortcuts
  140. map <leader>sn ]s " Next Spelling Mistake
  141. map <leader>sp [s " Previous Spelling Mistake
  142. map <leader>sa zg " Add Spelling
  143. map <leader>s? z= " Search Spelling
  144. """"
  145. " Misc
  146. """"
  147. " Toggle paste mode
  148. map <leader>pp :setlocal paste!<cr
  149. """"
  150. " Helper Functions
  151. """"
  152. function! InsertStatusLineColor(mode)
  153. " Insert Mode
  154. if a:mode == 'i'
  155. hi Statusline ctermfg=black ctermbg=green guifg=black guibg=green
  156. " Replace Mode
  157. elseif a:mode == 'r'
  158. hi Statusline ctermfg=black ctermbg=darkcyan guifg=black guibg=darkcyan
  159. " All Others (Visual,Select,Command-line,EX)
  160. else
  161. hi Statusline ctermfg=black ctermbg=darkred guifg=black guibg=darkred
  162. endif
  163. endfunction
  164. " Returns true if paste mode is enabled
  165. function! HasPaste()
  166. if &paste
  167. return 'Paste Mode '
  168. endif
  169. return ''
  170. endfunction