.vimrc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 <leader>u :!ctags -R .<CR>
  43. nnoremap <esc> :set nohlsearch<CR>
  44. " Local (scope) replace
  45. nnoremap gr gd[{V%::s/<C-R>///gc<left><left><left>
  46. " Global replace
  47. nnoremap gR gD:%s/<C-R>///gc<left><left><left>
  48. nnoremap Y y$
  49. nnoremap H ^
  50. nnoremap L $
  51. vnoremap H ^
  52. vnoremap L $
  53. inoremap jk <esc>
  54. inoremap <esc> <nop>
  55. inoremap <Left> <nop>
  56. inoremap <Right> <nop>
  57. inoremap <Up> <nop>
  58. inoremap <Down> <nop>
  59. " Dragvisuals keybinds
  60. vmap <expr> <LEFT> DVB_Drag('left')
  61. vmap <expr> <RIGHT> DVB_Drag('right')
  62. vmap <expr> <DOWN> DVB_Drag('down')
  63. vmap <expr> <UP> DVB_Drag('up')
  64. vmap <expr> D DVB_Duplicate()
  65. " Remove any introduced trailing whitespace after moving...
  66. let g:DVB_TrimWS = 1
  67. " }}}
  68. " ########## Abbreviations ########## {{{
  69. iabbrev ret return
  70. iabbrev @@ frans@tankernn.eu
  71. iabbrev ssig -- <cr>Frans Bergman<cr>frans@tankernn.eu
  72. " }}}
  73. " ########## File-specific settings ########## {{{
  74. autocmd FileType gitcommit,groff :set spell
  75. autocmd FileType vim :set foldmethod=marker
  76. autocmd BufNewFile,BufRead *.ms,*.me,*.mom,*.man set filetype=groff
  77. " }}}
  78. " ########## Plugins ########## {{{
  79. call plug#begin()
  80. Plug 'VundleVim/Vundle.vim'
  81. Plug 'tpope/vim-fugitive'
  82. Plug 'bling/vim-airline'
  83. Plug 'vim-airline/vim-airline-themes'
  84. Plug 'mkitt/tabline.vim'
  85. Plug 'tpope/vim-surround'
  86. Plug 'tpope/vim-repeat'
  87. Plug 'raimondi/delimitmate'
  88. Plug 'neomake/neomake'
  89. Plug 'fisadev/dragvisuals.vim'
  90. Plug 'maralla/completor.vim'
  91. Plug 'junegunn/fzf'
  92. call plug#end()
  93. " }}}
  94. " ########## Plugin Settings ########## {{{
  95. autocmd FileType java setlocal omnifunc=javacomplete#Complete
  96. call neomake#configure#automake('nrwi', 500)
  97. " Use TAB to complete when typing words, else inserts TABs as usual. Uses
  98. " dictionary, source files, and completor to find matching words to complete.
  99. " Note: usual completion is on <C-n> but more trouble to press all the time.
  100. " Never type the same word twice and maybe learn a new spellings!
  101. " Use the Linux dictionary when spelling is in doubt.
  102. function! Tab_Or_Complete() abort
  103. " If completor is already open the `tab` cycles through suggested completions.
  104. if pumvisible()
  105. return "\<C-N>"
  106. " If completor is not open and we are in the middle of typing a word then
  107. " `tab` opens completor menu.
  108. elseif col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^[[:keyword:][:ident:]]'
  109. return "\<C-R>=completor#do('complete')\<CR>"
  110. else
  111. " If we aren't typing a word and we press `tab` simply do the normal `tab`
  112. " action.
  113. return "\<Tab>"
  114. endif
  115. endfunction
  116. " Use `tab` key to select completions. Default is arrow keys.
  117. inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
  118. inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
  119. " Use tab to trigger auto completion.
  120. inoremap <expr> <Tab> Tab_Or_Complete()
  121. " }}}