Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fugitive

 Fugitive

This plugin by Tim Pope integrates Git into Vim and brings the editor one step closer to an IDE, as you can take the power to manage, view, and update your repository without ever once leaving the editor to go back to your shell. This talk will walk through some of the many ways you can use Fugitive to improve your workflow.

(Note: you may want to check out my slides from the recent DCBPW if you're not that familiar with git yet, as a primer for this talk)

This talk was initially prepared and presented at the May 9, 2016 Baltimore Vim meetup.

Stephen Belcher

May 09, 2016
Tweet

More Decks by Stephen Belcher

Other Decks in Technology

Transcript

  1. :Gstatus window mappings • <Ctrl-N>/<Ctrl-P> - next/previous file • <CR>

    - edit file under cursor (or cursor line) • D - Diff file (against index or prev commit) • U - Run ":Git checkout" or similar • cc - Run ":Git commit" • - (i.e., a dash/minus) - stage/unstage file under cursor • ...and many others (:help fugitive)
  2. :q

  3. Benefits of :Gcommit • Access to auto-complete if turned on

    • Can use fugitive :Gdiff and friends to easily inspect individual changes • Can, if absolutely necessary, update the staging area while commit window is open
  4. :Gedit Revisions • All standard Git revisions work (see the

    gitrevisions(7) man page) • Some shortcuts exist just for Fugitive: • - the current file as most-recently committed • ^ the current file as committed one commit ago • ~3 the current file as committed three commits ago • :0 the current file in the staging area
  5. :Gedit and...friends • :Gsplit - open a revision in a

    new split • :Gvsplit - open a revision in a new vertical split • :Gtabedit - open a revision in a new tab • :Gpedit - open a revision in the preview window • :Gbrowse - open a browser to the revision
  6. :Gbrowse • Fairly intelligent (supports line ranges, commit hashes, etc.)

    • Currently supports GitHub remotes • This is deprecated; use tpope's "vim-rhubarb" plugin • Will fall back to using a URL formed off "git-web" standard behavior • Other plugins needed for other custom hosts
  7. :Gwq - Writes a file to disk, and also stages

    it, and then closes the window
  8. :Gwq - Writes a file to disk, and also stages

    it, and then closes the window