vim:keys: Add more git mappings

This commit is contained in:
2022-03-30 14:36:40 +02:00
parent a8e72814c0
commit 241f315eec

View File

@@ -120,7 +120,25 @@ if exists('g:loaded_fugitive')
nnoremap <leader>gcd :Gcd<CR> nnoremap <leader>gcd :Gcd<CR>
else else
" only works if a file is already opened " only works if a file is already opened
nnoremap <leader>cd :cd %:h <Bar> cd `git rev-parse --show-toplevel`<CR> nnoremap <leader>gcd :cd %:h <Bar> cd `git rev-parse --show-toplevel`<CR>
endif
if exists('g:loaded_gitgutter')
" Add `g` prefix to hunk bindings
nmap <leader>ghs <Plug>(GitGutterStageHunk)
xmap <leader>ghs <Plug>(GitGutterStageHunk)
nmap <leader>ghu <Plug>(GitGutterUndoHunk)
nmap <leader>ghp <Plug>(GitGutterPreviewHunk)
" Add hunk/h version to textobject bindings that use `c` (for `change I
" presume?) (e.g. ic -> ih)
omap ih <Plug>(GitGutterTextObjectInnerPending)
omap ah <Plug>(GitGutterTextObjectOuterPending)
xmap ih <Plug>(GitGutterTextObjectInnerVisual)
xmap ah <Plug>(GitGutterTextObjectOuterVisual)
" Same for hunk navigation bindings
nmap [h <Plug>(GitGutterPrevHunk)
nmap ]h <Plug>(GitGutterNextHunk)
endif endif
" Y should behave like D & C does " Y should behave like D & C does