vimrc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. " Being vi-compatible disables more advanced features
  2. set nocompatible
  3. " Clear all existing autocommands first to avoid unwanted side effects
  4. if has("autocmd")
  5. autocmd!
  6. endif
  7. " Register plugins
  8. if filereadable(expand("~/dotfiles/vim/plugins.vim"))
  9. source ~/dotfiles/vim/plugins.vim
  10. endif
  11. " Automatically detect file types.
  12. filetype plugin indent on
  13. " Syntax highlighting.
  14. syntax on
  15. """"""""
  16. "" Tabs and Text Formatting
  17. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  18. set nowrap
  19. set cursorline " Highlight current line
  20. set expandtab " convert tab characters into spaces
  21. set tabstop=2 " actual tab press distance
  22. set softtabstop=2 " let backspace delete by indents
  23. set shiftround " indent to nearest tabstops
  24. set shiftwidth=2 " amount to indent with > and <
  25. set smarttab " backspace tabs where appropriate even if spaces
  26. set textwidth=80 " try to keep text within 80 characters
  27. set colorcolumn=+1 " mark out the limits of the textwidth
  28. set hidden " allow changing buffers without unsaved-warnings e.g. for argdo
  29. set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
  30. set splitright " Puts new vsplit windows to the right of the current
  31. set splitbelow " Puts new split windows to the bottom of the current
  32. set backspace=indent,eol,start " Backspace for dummies
  33. set linespace=0 " No extra spaces between rows
  34. set number " Line numbers on
  35. set relativenumber
  36. set showmatch " Show matching brackets/parenthesis
  37. set incsearch " Find as you type search
  38. set hlsearch " Highlight search terms
  39. set winminheight=0 " Windows can be 0 line high
  40. set ignorecase " Case insensitive search
  41. set smartcase " Case sensitive when uc present
  42. set wildmenu " Show list instead of just completing
  43. set modeline " Support vim modelines at the top of files
  44. set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
  45. set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
  46. set scrolloff=5 " Minimum lines to keep above and below cursor
  47. set list
  48. set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
  49. if has('persistent_undo')
  50. set undofile " So is persistent undo ...
  51. set undolevels=1000 " Maximum number of changes that can be undone
  52. set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
  53. endif
  54. """"""""
  55. "" Key Remaps
  56. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  57. let mapleader = ','
  58. " More convenient escape
  59. inoremap kj <ESC>
  60. inoremap jk <ESC>
  61. " Yank from the cursor to the end of the line, to be consistent with C and D.
  62. nnoremap Y y$
  63. " Remap vim's 'increment next number' to <C-b> since <C-a> is used by tmux.
  64. nnoremap <C-b> <C-a>
  65. " Allow using the repeat operator with a visual selection (!)
  66. " http://stackoverflow.com/a/8064607/127816
  67. vnoremap . :normal .<CR>
  68. """"""""
  69. "" Load Settings Files
  70. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  71. for filePath in split(globpath('~/dotfiles/vim/settings', '*.vim'), '\n')
  72. execute 'source' filePath
  73. endfor