.vimrc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. " default state
  2. set nocompatible
  3. set modelines=0 enc=utf-8 ffs=unix
  4. set ts=4 sw=4 sts=4 shiftround
  5. set autoindent smartindent
  6. set showmode showcmd laststatus=2
  7. set hidden nowrap number ruler cursorline
  8. set ignorecase smartcase hlsearch incsearch showmatch scrolloff=3
  9. set backspace=indent,eol,start
  10. set ttyfast lazyredraw vb
  11. set wildmenu wildmode=list:longest
  12. set foldmethod=syntax foldlevelstart=20
  13. set nobackup noswapfile
  14. silent! set undodir=$HOME/.vim/undo undolevels=1000 undoreload=10000 undofile
  15. " set color scheme
  16. set background=dark
  17. silent! colorscheme vividchalk
  18. " set leader-key to comma
  19. let mapleader=","
  20. " clear search
  21. nnoremap <leader><space> :noh<cr>
  22. " remap inconvenient keys
  23. inoremap <f1> <esc>
  24. nnoremap <f1> <esc>
  25. vnoremap <f1> <esc>
  26. " shortcut ; to : for less keys
  27. nnoremap ; :
  28. " toggle paste mode with F2
  29. set pastetoggle=<leader>p
  30. " quickly edit/reload the vimrc file (,ev or ,sv)
  31. nmap <silent> <leader>ev :e $MYVIMRC<cr>
  32. nmap <silent> <leader>sv :so $MYVIMRC<cr>
  33. " shortcut to force permissions
  34. cmap w!! w !sudo tee > /dev/null %
  35. " disable noise makers
  36. set noeb vb t_vb=
  37. " auto syntax highlighting and fold-settings
  38. filetype on
  39. syntax on
  40. filetype indent on
  41. filetype plugin on
  42. set foldmethod=syntax
  43. " define highlight for bad formatting
  44. highlight BadWhitespace ctermbg=red guibg=red
  45. " define au-group to prevent stacking execution
  46. augroup cureall
  47. " clear group
  48. au!
  49. " add markdown file recognition
  50. au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=markdown
  51. " missing syntax recognition
  52. au BufRead,BufNewFile *.py match BadWhitespace /*\t\*/
  53. au BufRead,BufNewFile *.py match BadWhitespace /\s\+$/
  54. " remove trailing whitespace automatically on save
  55. au BufWritePre * :%s/\s\+$//e
  56. " remove windows carriage returns automatically
  57. au BufWritePre * :%s/\r//e
  58. augroup END
  59. " tab autocompletion
  60. function! Tab_Or_Complete()
  61. if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'
  62. return "\<c-n>"
  63. else
  64. return "\<tab>"
  65. endif
  66. endfunction
  67. inoremap <tab> <c-r>=Tab_Or_Complete()<cr>
  68. set dictionary="/usr/share/dict/words"
  69. " load plugins
  70. silent! set runtimepath^=$HOME/.vim/bundle/ctrlp.vim
  71. silent! :helptags $HOME/.vim/doc