vi Basics

If you haven’t defined a core.editor for Git to use, it defaults to using vi for commit messages, interactive rebases, and other commands that require user input. Before we identify how to setup a core.editor you might need the following information:

How the *$#@& do I get out of vi?

First, don’t worry, everyone gets stuck in vi. Second, it is really easy to get out of vi using the following:

Saving the Commit

  1. Press the esc key.
  2. Enter :wq to save (or write) your commit message.

    You can enter :q to quit the editor without saving your commit message.

Discarding the Commit

  1. Press the esc key.
  2. Enter, :q!. This will discard the commit without discarding your changes. If you want to double check that your changes still exist, enter git status and your changes will still be displayed.

You have successfully gotten out of vi, nicely done.