nvim: git/fugitive: Add helper for git branch and checkout

This commit is contained in:
Sanchayan Maity 2021-03-19 12:11:37 +05:30
parent dfe344b2b9
commit ff7e6f524c
2 changed files with 11 additions and 0 deletions

View file

@ -1,2 +1,11 @@
" Disable whitespace highlighting in git buffer " Disable whitespace highlighting in git buffer
autocmd BufEnter <buffer> DisableWhitespace autocmd BufEnter <buffer> DisableWhitespace
xnoremap <Leader>gb :<C-U>call <SID>git_checkout_branch()<CR>
" We would like to checkout a branch by visually selecting a branch name in
" the output of git branch -a.
function! s:git_checkout_branch() abort
normal! `<v`>y
silent execute "Git checkout " . shellescape(@@)
endfunction

View file

@ -1,5 +1,7 @@
nnoremap <Leader>ga :Git fetch --all<CR> nnoremap <Leader>ga :Git fetch --all<CR>
xnoremap <Leader>gb :Git blame<CR> xnoremap <Leader>gb :Git blame<CR>
nnoremap <Leader>gb :Git branch<SPACE>
nnoremap <Leader>gB :Git checkout -b<SPACE>
nnoremap <Leader>gd :Ghdiffsplit!<CR> nnoremap <Leader>gd :Ghdiffsplit!<CR>
nnoremap <Leader>gD :Gvdiffsplit!<CR> nnoremap <Leader>gD :Gvdiffsplit!<CR>
nnoremap <Leader>gs :Git<CR> nnoremap <Leader>gs :Git<CR>