vimrc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. " Do not try to be compatible with vi
  2. set nocompatible
  3. " Formatting for JSON files
  4. au FileType json setlocal equalprg=python\ -m\ json.tool
  5. " Remap vim's 'increment next number' to <C-b> since <C-a> is used by tmux.
  6. nnoremap <C-b> <C-a>
  7. if has("autocmd")
  8. " Clear existing autocmd
  9. autocmd!
  10. endif
  11. " Use bundles config {{{
  12. if filereadable(expand("~/.vimrc.bundles"))
  13. source ~/.vimrc.bundles
  14. endif
  15. " }}}
  16. filetype plugin indent on " Automatically detect file types.
  17. if has("autocmd")
  18. " Source the vimrc file after saving it
  19. autocmd BufWritePost .vimrc nested source $MYVIMRC
  20. endif
  21. """"""""
  22. "" Tabs and Text Formatting
  23. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  24. syntax on " Syntax highlighting
  25. set nowrap
  26. set cursorline " Highlight current line
  27. set expandtab " convert tab characters into spaces
  28. set tabstop=2 " actual tab press distance
  29. set softtabstop=2 " let backspace delete by indents
  30. set shiftround " indent to nearest tabstops
  31. set shiftwidth=2 " amount to indent with > and <
  32. set smarttab " backspace tabs where appropriate even if spaces
  33. set textwidth=80 " try to keep text within 80 characters
  34. set colorcolumn=+1 " mark out the limits of the textwidth
  35. set hidden
  36. set mouse=a
  37. set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
  38. set splitright " Puts new vsplit windows to the right of the current
  39. set splitbelow " Puts new split windows to the bottom of the current
  40. set backspace=indent,eol,start " Backspace for dummies
  41. set linespace=0 " No extra spaces between rows
  42. set number " Line numbers on
  43. set relativenumber
  44. set showmatch " Show matching brackets/parenthesis
  45. set incsearch " Find as you type search
  46. set hlsearch " Highlight search terms
  47. set winminheight=0 " Windows can be 0 line high
  48. set ignorecase " Case insensitive search
  49. set smartcase " Case sensitive when uc present
  50. set wildmenu " Show list instead of just completing
  51. set modeline " Support vim modelines at the top of files
  52. "set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
  53. set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
  54. set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
  55. set scrolloff=5 " Minimum lines to keep above and below cursor
  56. set foldenable " Auto fold code
  57. set list
  58. set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
  59. if has('persistent_undo')
  60. set undofile " So is persistent undo ...
  61. set undolevels=1000 " Maximum number of changes that can be undone
  62. set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
  63. endif
  64. """"""""
  65. "" Key Remaps
  66. """"""""""""""""""""""""""""""""""""""""""""""""""""""""
  67. let mapleader = ','
  68. " More convenient escape
  69. inoremap kj <ESC>
  70. inoremap jk <ESC>
  71. " Yank from the cursor to the end of the line, to be consistent with C and D.
  72. nnoremap Y y$
  73. nnoremap <silent> <leader>w :set wrap!<CR>
  74. " Toggle paste mode - no autoindenting of pasted material
  75. nnoremap <silent> <leader>p :set paste! paste?<CR>
  76. " Toggle visible whitespace characters
  77. nnoremap <silent> <leader>l :set list!<CR>
  78. " Toggle scrollbind for moving multiple splits in sync together
  79. nnoremap <silent> <leader>s :set scrollbind! scrollbind?<CR>
  80. " Allow using the repeat operator with a visual selection (!)
  81. " http://stackoverflow.com/a/8064607/127816
  82. vnoremap . :normal .<CR>
  83. """"""""" Source local scripts/plugins
  84. for filePath in split(globpath('~/dotfiles/vim/settings', '*.vim'), '\n')
  85. execute 'source' filePath
  86. endfor