vimrc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. " Do not try to be compatible with vi
  2. set nocompatible
  3. if has("autocmd")
  4. " Clear existing autocmd
  5. autocmd!
  6. endif
  7. " Use bundles config {{{
  8. if filereadable(expand("~/.vimrc.bundles"))
  9. source ~/.vimrc.bundles
  10. endif
  11. " }}}
  12. filetype plugin indent on " Automatically detect file types.
  13. if has("autocmd")
  14. " Source the vimrc file after saving it
  15. autocmd BufWritePost .vimrc nested source $MYVIMRC
  16. endif
  17. """"""""
  18. "" Tabs and Text Formatting
  19. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  20. syntax on " Syntax highlighting
  21. set nowrap
  22. set cursorline " Highlight current line
  23. set expandtab " convert tab characters into spaces
  24. set tabstop=2 " actual tab press distance
  25. set softtabstop=2 " let backspace delete by indents
  26. set shiftround " indent to nearest tabstops
  27. set shiftwidth=2 " amount to indent with > and <
  28. set smarttab " backspace tabs where appropriate even if spaces
  29. set textwidth=80 " try to keep text within 80 characters
  30. set colorcolumn=+1 " mark out the limits of the textwidth
  31. set mouse=a
  32. set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
  33. set splitright " Puts new vsplit windows to the right of the current
  34. set splitbelow " Puts new split windows to the bottom of the current
  35. set backspace=indent,eol,start " Backspace for dummies
  36. set linespace=0 " No extra spaces between rows
  37. set number " Line numbers on
  38. set relativenumber
  39. set showmatch " Show matching brackets/parenthesis
  40. set incsearch " Find as you type search
  41. set hlsearch " Highlight search terms
  42. set winminheight=0 " Windows can be 0 line high
  43. set ignorecase " Case insensitive search
  44. set smartcase " Case sensitive when uc present
  45. set wildmenu " Show list instead of just completing
  46. set modeline " Support vim modelines at the top of files
  47. "set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
  48. set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
  49. set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
  50. set scrolloff=5 " Minimum lines to keep above and below cursor
  51. set foldenable " Auto fold code
  52. set list
  53. set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
  54. if has('persistent_undo')
  55. set undofile " So is persistent undo ...
  56. set undolevels=1000 " Maximum number of changes that can be undone
  57. set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
  58. endif
  59. """"""""
  60. "" Key Remaps
  61. """"""""""""""""""""""""""""""""""""""""""""""""""""""""
  62. let mapleader = ','
  63. " More convenient escape
  64. inoremap kj <ESC>
  65. inoremap jk <ESC>
  66. " Yank from the cursor to the end of the line, to be consistent with C and D.
  67. nnoremap Y y$
  68. nnoremap <silent> <leader>w :set wrap!<CR>
  69. " Toggle paste mode - no autoindenting of pasted material
  70. nnoremap <silent> <leader>p :set paste! paste?<CR>
  71. " Toggle visible whitespace characters
  72. nnoremap <silent> <leader>l :set list!<CR>
  73. " Toggle scrollbind for moving multiple splits in sync together
  74. nnoremap <silent> <leader>s :set scrollbind! scrollbind?<CR>
  75. " Backspace to clear current search (and stop highlighting)
  76. nnoremap <silent> <backspace> :call ClearSearch()<CR>
  77. function! ClearSearch()
  78. if (@/ != "")
  79. let @/=""
  80. redraw
  81. endif
  82. endfunction
  83. " Allow using the repeat operator with a visual selection (!)
  84. " http://stackoverflow.com/a/8064607/127816
  85. vnoremap . :normal .<CR>
  86. """"""""" Source local scripts/plugins
  87. for filePath in split(globpath('~/dotfiles/vim/settings', '*.vim'), '\n')
  88. execute 'source' filePath
  89. endfor