Skip to content

Fugitive: Vim

Shubham Shukla edited this page Oct 16, 2016 · 2 revisions

Vim's Fugitive Plugin: Git from the editor

####1. Git [args] : Runs any arbitrary git command

  • Commands that don't generate much output are easy to run with Git.

  • Aliases in .gitconfig would work with it.

    Examples:
  • Git checkout -b example

  • Git rm %

  • Git mv % target_path

  • Git add %

####2. Fugitive provide several commands analogous to the Git commands:

  • Git rm %: Gremove
    • Delete the current file and the corresponding Vim buffer
  • Git mv % target_path: Gmove target_path
    • Rename the current file and the corresponding Vim buffer
    • target_path is relative to current directory and /target_path will be relative to the root of the git repository.
  • Git add %: Gwrite
    • Stage the current file to the index
  • Git checkout %: Gread
    • Revert current file to last checked in version

####3. Gcommit

  • Opens a separate split window with the commit buffer.

  • Write the message into that and close the buffer to commit your changes.

    Advantages of Gcommit:
    • Auto-completion.
    • As the auto completion picks up the contents of the open buffers, this helps to auto-complete the name of any functions present in the buffers.
    • :help compl-generic

Clone this wiki locally