version_control.vim 935 B

12345678910111213141516171819202122232425262728
  1. " Fugitive Autocommands
  2. if has("autocmd")
  3. " Fugitive - Go up to previous tree object while exploring git tree with '..'
  4. autocmd User fugitive
  5. \ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' |
  6. \ nnoremap <buffer> .. :edit %:h<CR> |
  7. \ endif
  8. " Fugitive - Delete buffers when they are not active
  9. autocmd BufReadPost fugitive://* set bufhidden=delete
  10. endif
  11. " Search for conflict markers
  12. nnoremap <Leader>c /\v^[<\|=>]{7}( .*\|$)<CR>
  13. " Git commands with Fugitive
  14. nnoremap <silent> <Leader>gc :Gcommit -v<CR>
  15. nnoremap <silent> <Leader>gl :Glog<CR><CR>
  16. nnoremap <silent> <Leader>gap :Git add -p<CR>
  17. nnoremap <silent> <Leader>gs :Gstatus<CR>
  18. nnoremap <silent> <Leader>gd :Gdiff<CR>
  19. nnoremap <silent> <Leader>gb :Gblame<CR>
  20. " Get what's changed in an as-yet-unsaved file
  21. if !exists(':DiffOrig')
  22. command DiffOrig vert new | set buftype=nofile | read ++edit # | 0d_
  23. \ | diffthis | wincmd p | diffthis
  24. endif