.vimrc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. " Sensible.vim
  2. if exists('g:loaded_sensible') || &compatible
  3. finish
  4. else
  5. let g:loaded_sensible = 1
  6. endif
  7. if has('autocmd')
  8. filetype plugin indent on
  9. endif
  10. if has('syntax') && !exists('g:syntax_on')
  11. syntax enable
  12. endif
  13. " Use :help 'option' to see the documentation for the given option.
  14. set autoindent
  15. set backspace=indent,eol,start
  16. set complete-=i
  17. set smarttab
  18. set nrformats-=octal
  19. set ttimeout
  20. set ttimeoutlen=100
  21. set incsearch
  22. " Use <C-L> to clear the highlighting of :set hlsearch.
  23. if maparg('<C-L>', 'n') ==# ''
  24. nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
  25. endif
  26. set laststatus=2
  27. set ruler
  28. set wildmenu
  29. if !&scrolloff
  30. set scrolloff=1
  31. endif
  32. if !&sidescrolloff
  33. set sidescrolloff=5
  34. endif
  35. set display+=lastline
  36. if &encoding ==# 'latin1' && has('gui_running')
  37. set encoding=utf-8
  38. endif
  39. if &listchars ==# 'eol:$'
  40. set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
  41. endif
  42. if v:version > 703 || v:version == 703 && has("patch541")
  43. set formatoptions+=j " Delete comment character when joining commented lines
  44. endif
  45. if has('path_extra')
  46. setglobal tags-=./tags tags-=./tags; tags^=./tags;
  47. endif
  48. if &shell =~# 'fish$' && (v:version < 704 || v:version == 704 && !has('patch276'))
  49. set shell=/bin/bash
  50. endif
  51. set autoread
  52. if &history < 1000
  53. set history=1000
  54. endif
  55. if &tabpagemax < 50
  56. set tabpagemax=50
  57. endif
  58. if !empty(&viminfo)
  59. set viminfo^=!
  60. endif
  61. set sessionoptions-=options
  62. " Allow color schemes to do bright colors without forcing bold.
  63. if &t_Co == 8 && $TERM !~# '^linux\|^Eterm'
  64. set t_Co=16
  65. endif
  66. " Load matchit.vim, but only if the user hasn't installed a newer version.
  67. if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
  68. runtime! macros/matchit.vim
  69. endif
  70. inoremap <C-U> <C-G>u<C-U>
  71. " change terminal title
  72. set title
  73. " xdg-ish settings
  74. set undodir=~/.cache/vim/undo,.
  75. set backupdir=~/.cache/vim/backup,.
  76. set directory=~/.cache/vim/swap//,.
  77. " default indentation
  78. set shiftwidth=2
  79. set tabstop=4
  80. set expandtab
  81. " permanent undo history
  82. set undofile
  83. " allow switching buffers
  84. set hidden
  85. " always scroll
  86. set scrolloff=99
  87. " show line numbers
  88. set number
  89. set relativenumber
  90. " set wordwrap indent
  91. set nowrap
  92. set linebreak
  93. if exists("&breakindent")
  94. set breakindent
  95. set breakindentopt=shift:2,sbr
  96. endif
  97. " show whitespace
  98. set list
  99. " make a new copy of the file for backup
  100. " setting to no or auto messes with filewatchers
  101. set backupcopy=yes
  102. " ------ key bindings ------
  103. " ; as :
  104. nnoremap ; :
  105. vnoremap ; :
  106. " allow <ESC> via jj in insert mode
  107. inoremap jj <ESC>
  108. " fix j/k with wraps
  109. nnoremap j gj
  110. nnoremap k gk
  111. vnoremap j gj
  112. vnoremap k gk
  113. augroup formatting
  114. au!
  115. " strip trailing whitespace
  116. autocmd BufWritePre * :%s/\s\+$//e
  117. autocmd FileType markdown :set tw=80
  118. augroup end
  119. if filereadable(expand('~/.vimrc.local'))
  120. source ~/.vimrc.local
  121. endif