After writing commit message, just press Esc Button and then write :wq or :wq! and then Enter to close the unix file.
To save your work and exit press Esc and then :wq (w for write and q for quit).
Alternatively, you could both save and exit by pressing Esc and then :x
To set another editor run export EDITOR=myFavoriteEdior
on your terminal, where myFavoriteEdior
can be vi
, gedit
, subl
(for sublime) etc.
not really the answer to the VIM problem but you could use the command line to also enter the commit message:
git commit -m "This is the first commit"
You need to return to normal mode and save the commit message with either
<Esc>:wq
or
<Esc>:x
or
<Esc>ZZ
The Esc key returns you from insert mode to normal mode. The :wq, :x or ZZ sequence writes the changes and exits the editor.
Simply doing the vim "save and quit" command :wq
should do the trick.
In order to have Git open it in another editor, you need to change the Git core.editor
setting to a command which runs the editor you want.
git config --global core.editor "command to start sublime text 2"
This is in answer to your question...
I'd also like to know how to make it open up in Sublime Text 2 instead
For Windows:
git config --global core.editor "'C:/Program Files/Sublime Text 2/sublime_text.exe'"
Check that the path for sublime_text.exe
is correct and adjust if needed.
For Mac/Linux:
git config --global core.editor "subl -n -w"
If you get an error message such as:
error: There was a problem with the editor 'subl -n -w'.
Create the alias for subl
sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
Again check that the path matches for your machine.
For Sublime Text simply save cmd S
and close the window cmd W
to return to git.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With