vimrc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 showmatch " Show matching brackets/parenthesis
  39. set incsearch " Find as you type search
  40. set hlsearch " Highlight search terms
  41. set winminheight=0 " Windows can be 0 line high
  42. set ignorecase " Case insensitive search
  43. set smartcase " Case sensitive when uc present
  44. set wildmenu " Show list instead of just completing
  45. set modeline " Support vim modelines at the top of files
  46. "set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
  47. set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
  48. set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
  49. set scrolloff=5 " Minimum lines to keep above and below cursor
  50. set foldenable " Auto fold code
  51. set list
  52. set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
  53. if has('persistent_undo')
  54. set undofile " So is persistent undo ...
  55. set undolevels=1000 " Maximum number of changes that can be undone
  56. set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
  57. endif
  58. """"""""
  59. "" Key Remaps
  60. """"""""""""""""""""""""""""""""""""""""""""""""""""""""
  61. let mapleader = ','
  62. " More convenient escape
  63. inoremap kj <ESC>
  64. inoremap jk <ESC>
  65. " Yank from the cursor to the end of the line, to be consistent with C and D.
  66. nnoremap Y y$
  67. nnoremap <silent> <leader>w :set wrap!<CR>
  68. " Toggle paste mode - no autoindenting of pasted material
  69. nnoremap <silent> <leader>p :set paste! paste?<CR>
  70. " Toggle visible whitespace characters
  71. nnoremap <silent> <leader>l :set list!<CR>
  72. " Toggle scrollbind for moving multiple splits in sync together
  73. nnoremap <silent> <leader>s :set scrollbind! scrollbind?<CR>
  74. " Backspace to clear current search (and stop highlighting)
  75. nnoremap <silent> <backspace> :call ClearSearch()<CR>
  76. function! ClearSearch()
  77. if (@/ != "")
  78. let @/=""
  79. redraw
  80. endif
  81. endfunction
  82. " Allow using the repeat operator with a visual selection (!)
  83. " http://stackoverflow.com/a/8064607/127816
  84. vnoremap . :normal .<CR>
  85. """"""""" Source local scripts/plugins
  86. for filePath in split(globpath('~/dotfiles/vim/settings', '*.vim'), '\n')
  87. execute 'source' filePath
  88. endfor