vimrc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. " Automatically detect file types.
  7. filetype plugin indent on
  8. endif
  9. " Syntax highlighting.
  10. if has("syntax")
  11. syntax enable
  12. endif
  13. " Register plugins
  14. if filereadable(expand("~/dotfiles/vim/plugins.vim"))
  15. source ~/dotfiles/vim/plugins.vim
  16. endif
  17. """"""""
  18. "" Tabs and Text Formatting
  19. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  20. set nowrap
  21. set cursorline " Highlight current line
  22. set expandtab " convert tab characters into spaces
  23. set tabstop=2 " actual tab press distance
  24. set softtabstop=2 " let backspace delete by indents
  25. set shiftround " indent to nearest tabstops
  26. set shiftwidth=2 " amount to indent with > and <
  27. set smarttab " backspace tabs where appropriate even if spaces
  28. set textwidth=80 " try to keep text within 80 characters
  29. set colorcolumn=+1 " mark out the limits of the textwidth
  30. set hidden " allow changing buffers without unsaved-warnings e.g. for argdo
  31. set mouse=a " Mouse support enabled.
  32. set splitright " Puts new vsplit windows to the right of the current
  33. set splitbelow " Puts new split windows to the bottom of the current
  34. set backspace=indent,eol,start " Backspace for dummies
  35. set linespace=0 " No extra spaces between rows
  36. set relativenumber " Show line numbers relative to current line, and
  37. set number " Show the actual line number on current line.
  38. set showmatch " Show matching brackets/parenthesis
  39. set incsearch " Find as you type search
  40. set hlsearch " Highlight search terms
  41. set ignorecase " Case insensitive search
  42. set smartcase " Case sensitive when uc present
  43. set winminheight=0 " Windows can be 0 line high
  44. set wildmenu " Show list instead of just completing
  45. set modeline " Support vim modelines at the top of files
  46. set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
  47. set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
  48. set scrolloff=10 " Minimum lines to keep above and below cursor
  49. set sidescroll=1
  50. set sidescrolloff=15
  51. set linebreak " Break on words when wrapping.
  52. set list
  53. set listchars=tab:>\ ,trail:.,extends:#,nbsp:#
  54. " Persistent undo is great!
  55. if has('persistent_undo')
  56. set undofile
  57. set undolevels=1000 " Max changes that can be undone
  58. set undoreload=10000 " Max lines to save for undo on a buffer reload
  59. endif
  60. " Join (J) options
  61. set nojoinspaces " Prevents inserting two spaces after punctuation
  62. if v:version > 703 || v:version == 703 && has("patch541")
  63. set formatoptions+=j " Remove comment characters when joining comment lines.
  64. endif
  65. """"""""
  66. "" Mappings
  67. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  68. let mapleader = ' '
  69. " Save changes to a file
  70. nmap <silent> <Leader>w :up<CR>
  71. " Close a file
  72. nmap <silent> <Leader>q :q<CR>
  73. " More convenient escape
  74. inoremap kj <Esc>
  75. inoremap jk <Esc>
  76. " Yank from the cursor to the end of the line, to be consistent with C and D.
  77. nnoremap Y y$
  78. " Remap vim's 'increment next number' to <C-b> since <C-a> is used by tmux.
  79. nnoremap <C-b> <C-a>
  80. " Allow using the repeat operator with a visual selection (!)
  81. " http://stackoverflow.com/a/8064607/127816
  82. vnoremap . :normal .<CR>
  83. """"""""
  84. "" Load Settings Files
  85. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  86. for filePath in split(globpath('~/dotfiles/vim/settings', '*.vim'), '\n')
  87. execute 'source' filePath
  88. endfor