From 7eb4a29b4dd63285ae38108a965ea98d6f4a1697 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Tue, 12 Apr 2022 17:13:23 +0200 Subject: [PATCH] vim:keys: Improve and add new git mappings - Drop the mapping for `:Gcd` as I rarely use it and prefer to commit with one keystroke less. - Add the current file instead of calling `git add -p` for the whole repository. If I want to add hunks I can do that with the gitgutter mappings. - Add mappings to stash and checkout the current file. - Use mnemonic 'add' instead of 'stage' for `GitGutterStageHunk` mappings. TODO: Extend gitgutter for a `GitGutterStashHunk` function --- .config/vim/vimrc.d/40-keys.vim | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.config/vim/vimrc.d/40-keys.vim b/.config/vim/vimrc.d/40-keys.vim index e6b634b..89cffe2 100644 --- a/.config/vim/vimrc.d/40-keys.vim +++ b/.config/vim/vimrc.d/40-keys.vim @@ -116,9 +116,11 @@ vnoremap # y?\V=escape(@",'?\') nnoremap gp '`[' . strpart(getregtype(), 0, 1) . '`]' if exists('g:loaded_fugitive') - nnoremap ga :G add -p - nnoremap gcc :G commit - nnoremap gcd :Gcd + nmap gc :G commit + + nmap ga :G add -- % + nmap gs :G stash -- % + nmap gu :G checkout -- % else " only works if a file is already opened nnoremap gcd :cd %:h cd `git rev-parse --show-toplevel` @@ -126,8 +128,11 @@ endif if exists('g:loaded_gitgutter') " Add `g` prefix to hunk bindings - nmap ghs (GitGutterStageHunk) - xmap ghs (GitGutterStageHunk) + + " Mnemonic: "git hunk " + nmap gha (GitGutterStageHunk) + xmap gha (GitGutterStageHunk) + " TODO: nmap ghs (GitGutterStashHunk) nmap ghu (GitGutterUndoHunk) nmap ghp (GitGutterPreviewHunk)