.vimrc 3.7 KB

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