Anybody using Git straight out of the box on the command line is likely to have found themselves suddenly stuck in a Vim editor. If you’re not used to Vim, this can be a highly discombobulating experience. Here’s how to escape!
- Quick Guide:
- Type i to get into insert mode
- (no need for colon)
- (if it’s worked, you’ll see “– INSERT –” at bottom of screen
- Type your commit message
- Click Esc
- Type :wq to save and quit
- Or type :q! to quit without saving
- Hit Enter
- Type i to get into insert mode
Changing your Default Git Editor
- You don’t have to have Vim as your default editor! You can change to an editor of your choice (eg Notepad)
- Note that these instructions were written for Windows. I don’t know about other operating systems but I’m guessing it’ll be similar
- Find and open your .gitconfig file
- (probably here: C:\Users\[user-name])
- Add this section to the bottom:
- [core]
- editor = ‘C:/Program Files (x86)/Notepad++/notepad++.exe’
- Save and close the file.
- When you’re committing with git, just write git commit and press Enter. It will pop open Notepad++.
- Write your commit message at the top of the file, and save and close the file. Done!
- …but it doesn’t always work like that, in which case you might have to go back to VIM and just learn the VIM basics
- Find and open your .gitconfig file
- More here: http://stackoverflow.com/questions/2596805/how-do-i-make-git-use-the-editor-of-my-choice-for-commits