From 8c3f15235646ff05ee38703f05de46c00cc4dc20 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 13 Jul 2019 23:53:26 +0200 Subject: [PATCH] [ADD][VIM] Vim-fugitive mappings All fugitive specific mappings are prefixed by - ga : add file in current buffer - gb : add blame information to the left of current buffer - gc : commit all staged changes, open a new tab with commit message - gd : open a diff view - gs : open a buffer with the current git status - gm : use git-mv to rename a file in the project You can use the do and dp commands while in diff view to stage a partial commit. Mappings have been added to make them work in visual mode too. --- vim/.vimrc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/vim/.vimrc b/vim/.vimrc index dc23da7..01a69f5 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -192,6 +192,8 @@ let g:UltiSnipsEditSplit="vertical" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Mappings """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Miscellaneous mappings +"""""""""""""""""""""""" " Yank until the end of line with Y, to be more consistent with D and C nnoremap Y y$ @@ -207,6 +209,7 @@ map es :source $MYVIMRC noremap m :silent! :make! \| :redraw! " Mapping for quickfix bindings +""""""""""""""""""""""""""""""" " Next and previous in quick-fix list nmap fn (qf_qf_next) nmap fp (qf_qf_previous) @@ -218,6 +221,7 @@ nmap tf (qf_qf_toggle) nmap tl (qf_loc_toggle) " Fuzzy file finder bindings +"""""""""""""""""""""""""""" " Only git-tracked files, Vim needs to be in a Git repository nmap fg :GFiles " All files @@ -231,9 +235,26 @@ nmap ft :BTags " Tags in all project files nmap fT :Tags +" Git and diff mappings +""""""""""""""""""""""" +" Visual bindings for merging diffs as in normal mode +xnoremap dp :diffput +xnoremap do :diffget +" Git add current file +nnoremap ga :Git add %:p +" Open status window +nnoremap gs :Gstatus +" Open diff view of current buffer: the right/down window is the new version +nnoremap gd :Gdiffsplit! +" Use git-mv and rename the buffer, backspace and add '!' to use the '-f' flag +nnoremap gm :Gmove +" Open a buffer to the left with blame information +nnoremap gb :Gblame + """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Status line """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Show ctags and cscopes generation in status line set statusline+=%{gutentags#statusline()} """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -241,5 +262,5 @@ set statusline+=%{gutentags#statusline()} """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let git_settings = system("git config --get vim.settings") if strlen(git_settings) - exe "set" git_settings + exe "set" git_settings endif