vimrc 4.0 KB

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