vimrc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 splitright " Puts new vsplit windows to the right of the current
  32. set splitbelow " Puts new split windows to the bottom of the current
  33. set backspace=indent,eol,start " Backspace for dummies
  34. set linespace=0 " No extra spaces between rows
  35. set relativenumber " Show line numbers relative to current line, and
  36. set number " Show the actual line number on current line.
  37. set showmatch " Show matching brackets/parenthesis
  38. set incsearch " Find as you type search
  39. set hlsearch " Highlight search terms
  40. set ignorecase " Case insensitive search
  41. set smartcase " Case sensitive when uc present
  42. set winminheight=0 " Windows can be 0 line high
  43. set wildmenu " Show list instead of just completing
  44. set modeline " Support vim modelines at the top of files
  45. set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
  46. set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
  47. set scrolloff=10 " Minimum lines to keep above and below cursor
  48. set sidescroll=1
  49. set sidescrolloff=15
  50. set list
  51. set listchars=tab:>\ ,trail:.,extends:#,nbsp:#
  52. if has('persistent_undo')
  53. set undofile " So is persistent undo ...
  54. set undolevels=1000 " Maximum number of changes that can be undone
  55. set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
  56. endif
  57. " Join (J) options
  58. set nojoinspaces " Prevents inserting two spaces after punctuation
  59. if v:version > 703 || v:version == 703 && has("patch541")
  60. set formatoptions+=j " Remove comment characters when joining comment lines.
  61. endif
  62. """"""""
  63. "" Key Remaps
  64. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  65. let mapleader = ' '
  66. " Save changes to a file
  67. nmap <silent> <Leader>w :up<CR>
  68. " Close a file
  69. nmap <silent> <Leader>q :q<CR>
  70. " More convenient escape
  71. inoremap kj <Esc>
  72. inoremap jk <Esc>
  73. " Yank from the cursor to the end of the line, to be consistent with C and D.
  74. nnoremap Y y$
  75. " Remap vim's 'increment next number' to <C-b> since <C-a> is used by tmux.
  76. nnoremap <C-b> <C-a>
  77. " Allow using the repeat operator with a visual selection (!)
  78. " http://stackoverflow.com/a/8064607/127816
  79. vnoremap . :normal .<CR>
  80. """"""""
  81. "" Load Settings Files
  82. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  83. for filePath in split(globpath('~/dotfiles/vim/settings', '*.vim'), '\n')
  84. execute 'source' filePath
  85. endfor