vimrc 3.6 KB

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