vimrc 4.0 KB

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