Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
–
–
This is mostly a question about using VIM, so let's to it.
First, you need to setup Git to use Vim as the editor, if that's not the default for you. You can do that by adding to the git config of your choice (none which is local,
--global
or
--system
):
git config --global core.editor vim
Then when you commit, you don't add the
-m
parameter, leave it blank:
git commit
// or
git commit -a
After that, you are in VIM, in escape mode. You then need to start insert mode to write. The simplest way is to type
i
, and a message will appear on the bottom (
-- INSERT --
). You are in insert mode and you can now type in your message.
After that, you must exit insert mode, and you do that by pressing
Esc
once. The
-- INSERT --
message on the bottom should vanish. You are now in escape mode again, and you must save and quit.
That is done by using the
:
key to enter command mode and typing the command
wq
or
x
, leaving you with either
:wq
or
:x
typed at the bottom.
w
stands for write and
q
for quit, so
wq
is write and quit.
x
is an alias for
wq
.
After that you just press
Enter
and you're done, out of VIM.
If you have any doubts post a comment and I'll add it up.
–
–
a vim console will open automatically, when using the 'normal' settings.
In the vim-console, you will have to press
i
first, than you will be able to enter your text at the position of the cursor.
Next, you will have to press
ESC
to leave the input menu. To save your changes, type
:wq
(write & quit, the colon is to enter the command-mode), then hit
ENTER
.
Please have a look at the
help files
.
–
If you don't pass in the
-m
parameter into
git commit
then by default Git will open vim to allow the user to write the commit message.
To change the editor to something different run the following command (eg. for vim);
git config --global core.editor "vim"
–
If you don't use the -m
flag, then the editor will be opened. By default, it's vim but you can change it:
git config --global core.editor nano
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.