April 2, 2019 · Don't Forget linux mac
fugitive.vim shortcuts & cheatsheet
The fugitive plugin is a really nice git wrapper for Vim.
Basics:
:Git # Run any arbitrary git command from inside Vim
:Gwrite # Stage the current file to the index
:Gread # Revert current file to last checked in version
:Gremove # Delete the current file and the corresponding Vim buffer
:Gmove # Rename the current file and the corresponding Vim buffer
:Gcommit # Opens up a commit window in a split window
:Ggrep keyword # Will search for 'keyword' in working copy files (excluding untracked files)
History:
:Gblame # Opens a vertically split window containing annotations for each line of the file: the last commit reference, with author and timestamp. The split windows are bound, so that when you scroll one, the other window will follow
:Gstatus # Opens a status window. Open file with an enter, jump directly between files with {ctrl-n} and {ctrl-p}
:Gedit # With no arguments from a working tree file, it will open the index version of that file. Use the optional {:index} (such as ':Gedit :1') to open the provided index
:Gdiff # Performs a vimdiff against the index version of the file. Opens a vertical split window (index file on the left, working copy on the right). Navigate through hunks using {[c} for previous and {]c} for next
:Glog # Loads all previous revisions of the current file into the quickfix list. Use it with '-- %' to load all ancestral commit objects that touched the current file into the quickfix list. Use it with '--grep=keyword --' to search for 'keyword' in all ancestral commit messages. Or '-Skeyword --' to search for 'keyword' in the diff for each ancestral commit. Jump between previous and next quickfix item with {:cprev} or {:cnext}, respectively