dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 1376ebf92a8b8a6b8a4c904ae420c75a5d3d4915
parent edd44aa16dff6166919b33c89bcd1771556b02d8
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Sun, 21 Apr 2019 13:05:54 +0200

Update keybinds using mainly built-in functionality

Diffstat:
M.vim/plugin/00-general.vim | 10++++++++++
M.vim/plugin/keybinds.vim | 121+++++++++++++++++++++++++++++++++++++------------------------------------------
M.vim/plugins.vim | 1+
3 files changed, 68 insertions(+), 64 deletions(-)

diff --git a/.vim/plugin/00-general.vim b/.vim/plugin/00-general.vim @@ -33,3 +33,13 @@ elseif executable("ag") set grepprg=ag\ --nogroup\ --nocolor\ --ignore-case\ --column set grepformat=%f:%l:%c:%m,%f:%l:%m endif + +function! StripTrailingWhitespace() + if !&binary && &filetype != 'diff' + normal mz + normal Hmy + %s/\s\+$//e + normal 'yz<cr> + normal `z + endif +endfunction diff --git a/.vim/plugin/keybinds.vim b/.vim/plugin/keybinds.vim @@ -4,60 +4,65 @@ let mapleader="\<Space>" " Shortcut to reload .vimrc and ~/.vim/plugin/*.vim -nnoremap <leader>R :source $MYVIMRC<CR>:runtime! plugin/*.vim<CR>:echo "Configuration reloaded"<CR> +nnoremap <leader>R :source $MYVIMRC<cr>:runtime! plugin/*.vim<cr>:echo "Configuration reloaded"<cr> -nnoremap <Leader>w :w<CR> -nnoremap <Leader>W :wa<CR> -nnoremap <Leader>q :q<CR> -nnoremap <leader>Q :qa<CR> -nnoremap <Leader>x :x<CR> - -" Jump to previous buffer -nnoremap <leader><tab> :e#<CR> +nnoremap <Leader>w :w<cr> +nnoremap <Leader>W :wa<cr> +nnoremap <Leader>q :q<cr> +nnoremap <leader>Q :qa<cr> +nnoremap <Leader>x :x<cr> " toggle spelling -nnoremap <leader>s :set spell!<CR> +nnoremap <leader>s :set spell!<cr> " toggle line numbering -nnoremap <leader>N :set number!<CR> +nnoremap <leader>N :set number!<cr> " toggle relative line numbering -nnoremap <leader>n :set relativenumber!<CR> +nnoremap <leader>n :set relativenumber!<cr> " netrw -nnoremap <leader>d :Lex<CR> -nnoremap <leader>h :Hex<CR> - -" Toggle TAB and EOL symbols -"nnoremap <leader>l :set list!<CR> - -nnoremap <leader>e :e -nnoremap <leader>% :vsplit -nnoremap <leader>" :split +nnoremap <leader>d :Lex<cr> +nnoremap <leader>h :Hex<cr> + +" https://www.vi-improved.org/recommendations/ +"" add files with wildcards +nnoremap <leader>a :argadd <c-r>=fnameescape(expand('%:p:h'))<cr>/*<c-d> +"" go to buffer prompt +nnoremap <leader>b :b <c-d> +"" go to file open prompt +nnoremap <leader>e :e **/ +nnoremap <leader>g :grep<space> +"" ilist function from qlist, make ilist go into quickfix window +nnoremap <leader>i :Ilist<space> +"" taglist jump command line +nnoremap <leader>j :tjump / +nnoremap <leader>m :make<cr> +"" strip trailing whitespace +nnoremap <leader>s :call StripTrailingWhitespace()<cr> +"" go to last used buffer +nnoremap <leader><tab> :b#<cr> + +nnoremap <leader>% :vsplit<space> +nnoremap <leader>" :split<space> " shortcuts to commonly used files -nnoremap <leader>CC :e $MYVIMRC<CR> +nnoremap <leader>CC :e $MYVIMRC<cr> nnoremap <leader>CO :e ~/.vim/plugin/ -nnoremap <leader>CK :e ~/.vim/plugin/keybinds.vim<CR> -nnoremap <leader>CA :e ~/.vim/plugin/appearance.vim<CR> -nnoremap <leader>CG :e ~/.vim/plugin/00-general.vim<CR> -nnoremap <leader>CP :e ~/.vim/plugins.vim<CR> -nnoremap <leader>T :e ~/doc/todo.md<CR> -nnoremap <leader>b :e $BIB \| :windo normal G<CR> +nnoremap <leader>CK :e ~/.vim/plugin/keybinds.vim<cr> +nnoremap <leader>CA :e ~/.vim/plugin/appearance.vim<cr> +nnoremap <leader>CG :e ~/.vim/plugin/00-general.vim<cr> +nnoremap <leader>CP :e ~/.vim/plugins.vim<cr> +nnoremap <leader>T :e ~/doc/todo.md<cr> +nnoremap <leader>B :e $BIB \| :windo normal G<cr> -nnoremap <leader>r :read !scholarref +nnoremap <leader>r :read !scholarref<space> " insert date and time -nnoremap <leader>D :read !date +"\# \%Y-\%m-\%d \%T \%Z (\%z UTC)"<CR> - -" job execution -nnoremap <leader>m :Make<CR> -nnoremap <leader>M :Make!<CR> -nnoremap <leader>! :Start! -nnoremap <leader>c :Copen<CR> +nnoremap <leader>D :read !date +"\# \%Y-\%m-\%d \%T \%Z (\%z UTC)"<cr> " toggle x mark in checklist fields -nnoremap <leader>X :s/\[[x ]\]/\=submatch(0) == '[x]' ? '[ ]': '[x]'/<CR>:noh<CR> +nnoremap <leader>X :s/\[[x ]\]/\=submatch(0) == '[x]' ? '[ ]': '[x]'/<cr>:noh<cr> if exists(':tnoremap') " escape from terminal mode @@ -75,42 +80,33 @@ if exists(':tnoremap') end " launch terminal in current window -nnoremap <leader><CR> :terminal<CR> +nnoremap <leader><cr> :terminal<cr> " bindings to fugitive -nnoremap <leader>ga :Gwrite<CR> -nnoremap <leader>gm :Gmove -nnoremap <leader>gb :Gblame<CR> -nnoremap <leader>gw :Gbrowse<CR> -nnoremap <leader>gs :Gstatus<CR> -nnoremap <leader>gc :Gcommit -v -S<CR> -nnoremap <leader>gp :Gpush<CR> -nnoremap <leader>gP :Gpull<CR> +nnoremap <leader>ga :Gwrite<cr> +nnoremap <leader>gm :Gmove +nnoremap <leader>gb :Gblame<cr> +nnoremap <leader>gw :Gbrowse<cr> +nnoremap <leader>gs :Gstatus<cr> +nnoremap <leader>gc :Gcommit -v -S<cr> +nnoremap <leader>gp :Gpush<cr> +nnoremap <leader>gP :Gpull<cr> " Use home row keys as Esc inoremap jk <Esc> -nnoremap , :ls<CR>:buffer<Space> " using fzf.vim augroup FzfBinds autocmd VimEnter * if exists(":Buffers") | - \ exe "nnoremap , :Buffers<CR>" | - \ exe "nnoremap <leader>o :History<CR>" | - \ exe "nnoremap <leader>f :Files<CR>" | - \ exe "nnoremap <leader>F :GFiles<CR>" | - \ exe "nnoremap <leader>l :Lines<CR>" | - \ exe "nnoremap <leader>L :BLines<CR>" | - \ exe "nnoremap <leader>t :Tags<CR>" | + \ exe "nnoremap <leader>o :History<cr>" | + \ exe "nnoremap <leader>f :Files<cr>" | + \ exe "nnoremap <leader>F :GFiles<cr>" | + \ exe "nnoremap <leader>l :Lines<cr>" | + \ exe "nnoremap <leader>L :BLines<cr>" | + \ exe "nnoremap <leader>t :Tags<cr>" | \ endif augroup end -" align things into columns interactively -xnoremap <silent> <Enter> :EasyAlign<cr> -" Start interactive EasyAlign in visual mode (e.g. vipga) -xnoremap ga <Plug>(EasyAlign) -" Start interactive EasyAlign for a motion/text object (e.g. gaip) -nnoremap ga <Plug>(EasyAlign) - " ALE navigation nnoremap <silent> [W :ALEFirst<cr> nnoremap <silent> [w :ALEPreviousWrap<cr> @@ -133,6 +129,3 @@ nnoremap <silent> [c :cprevious<cr> " <C-x><C-v>: vim command-line " <C-x><C-v>: omni completion " <C-x>s: spelling suggestions -" Other: -" <C-x><C-u>: emoji -" <C-x><C-z>: unicode diff --git a/.vim/plugins.vim b/.vim/plugins.vim @@ -13,6 +13,7 @@ Plug 'Yggdroot/indentLine' " show indentation level with vertical lines Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf.vim' " fzf commands from within vim Plug 'ludovicchabant/vim-gutentags' " automatic tag generation +"Plug 'tomtom/ttags_vim' " tag navigation Plug 'tpope/vim-eunuch' " :SudoWrite, :Rename, :Move, etc """""" Syntax checking """"""