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.

227 lines
4.0 KiB

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