.vimrc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. " ########## General ########## {{{
  2. syntax on
  3. colorscheme elflord
  4. let g:airline_theme='atomic'
  5. set encoding=utf-8
  6. set fileencoding=utf-8
  7. set wildmenu
  8. set autoindent
  9. set smartindent
  10. set incsearch
  11. set smarttab
  12. set ignorecase
  13. set smartcase
  14. set number relativenumber
  15. set so=7
  16. set tabstop=4 shiftwidth=4
  17. set expandtab
  18. let mapleader = ","
  19. let maplocalleader = "\\"
  20. " }}}
  21. " ########## Highlighting ########## {{{
  22. highlight ExtraWhitespace ctermbg=red guibg=red
  23. match ExtraWhitespace /\s\+$/
  24. augroup trailingwhitespace
  25. autocmd!
  26. autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/
  27. augroup END
  28. " Tabs
  29. set list
  30. set listchars=tab:\|\
  31. " }}}
  32. " ########## Keybinds ########## {{{
  33. nnoremap <leader>ev :vsplit $MYVIMRC<cr>
  34. nnoremap <leader>sv :source $MYVIMRC<cr>
  35. nnoremap <leader>f :FZF<cr>
  36. nnoremap <leader>gs :Gstatus<cr>
  37. nnoremap <leader>gc :Gcommit<cr>
  38. nnoremap <leader>gr :Git rebase -i
  39. noremap <leader>c :w! \| !compiler <c-r>%<CR>
  40. noremap <leader>p :!opout <c-r>%<CR><CR>
  41. " Local (scope) replace
  42. nnoremap gr gd[{V%::s/<C-R>///gc<left><left><left>
  43. " Global replace
  44. nnoremap gR gD:%s/<C-R>///gc<left><left><left>
  45. nnoremap Y y$
  46. nnoremap H ^
  47. nnoremap L $
  48. vnoremap H ^
  49. vnoremap L $
  50. inoremap jk <esc>
  51. inoremap <esc> <nop>
  52. inoremap <Left> <nop>
  53. inoremap <Right> <nop>
  54. inoremap <Up> <nop>
  55. inoremap <Down> <nop>
  56. " Dragvisuals keybinds
  57. vmap <expr> <LEFT> DVB_Drag('left')
  58. vmap <expr> <RIGHT> DVB_Drag('right')
  59. vmap <expr> <DOWN> DVB_Drag('down')
  60. vmap <expr> <UP> DVB_Drag('up')
  61. vmap <expr> D DVB_Duplicate()
  62. " Remove any introduced trailing whitespace after moving...
  63. let g:DVB_TrimWS = 1
  64. " }}}
  65. " ########## Abbreviations ########## {{{
  66. iabbrev ret return
  67. iabbrev @@ frans@tankernn.eu
  68. iabbrev ssig -- <cr>Frans Bergman<cr>frans@tankernn.eu
  69. " }}}
  70. " ########## File-specific settings ########## {{{
  71. autocmd FileType gitcommit,groff :set spell
  72. autocmd FileType vim :set foldmethod=marker
  73. autocmd BufNewFile,BufRead *.ms,*.me,*.mom,*.man set filetype=groff
  74. " }}}
  75. " ########## Plugins ########## {{{
  76. call plug#begin()
  77. Plug 'VundleVim/Vundle.vim'
  78. Plug 'tpope/vim-fugitive'
  79. Plug 'bling/vim-airline'
  80. Plug 'vim-airline/vim-airline-themes'
  81. Plug 'mkitt/tabline.vim'
  82. Plug 'tpope/vim-surround'
  83. Plug 'tpope/vim-repeat'
  84. Plug 'raimondi/delimitmate'
  85. Plug 'neomake/neomake'
  86. Plug 'fisadev/dragvisuals.vim'
  87. Plug 'maralla/completor.vim'
  88. Plug 'junegunn/fzf'
  89. call plug#end()
  90. " }}}
  91. " ########## Plugin Settings ########## {{{
  92. autocmd FileType java setlocal omnifunc=javacomplete#Complete
  93. call neomake#configure#automake('nrwi', 500)
  94. " Use TAB to complete when typing words, else inserts TABs as usual. Uses
  95. " dictionary, source files, and completor to find matching words to complete.
  96. " Note: usual completion is on <C-n> but more trouble to press all the time.
  97. " Never type the same word twice and maybe learn a new spellings!
  98. " Use the Linux dictionary when spelling is in doubt.
  99. function! Tab_Or_Complete() abort
  100. " If completor is already open the `tab` cycles through suggested completions.
  101. if pumvisible()
  102. return "\<C-N>"
  103. " If completor is not open and we are in the middle of typing a word then
  104. " `tab` opens completor menu.
  105. elseif col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^[[:keyword:][:ident:]]'
  106. return "\<C-R>=completor#do('complete')\<CR>"
  107. else
  108. " If we aren't typing a word and we press `tab` simply do the normal `tab`
  109. " action.
  110. return "\<Tab>"
  111. endif
  112. endfunction
  113. " Use `tab` key to select completions. Default is arrow keys.
  114. inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
  115. inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
  116. " Use tab to trigger auto completion.
  117. inoremap <expr> <Tab> Tab_Or_Complete()
  118. " }}}