VIM text editor instructions

On Wednesday, October 20, 2010 0 comments

So, while using msysgit, you will more than likely end up using VIM to write text at least once(unless you change it, which I will tell you how to do that at the end of this tutorial). A good example of when VIM is required is during a commit. The editor is extremely difficult to understand, especially without any instructions, which is exactly what this tutorial is for.

Lets make an assumption that I just made some change to the code; how bout I added the ability for the player to change colors. Once I had the job finished, I would commit:

git commit -a

This would immediately start the text editor, VIM. It would have a print out something like this:

(Your cursor should be here)
#############################
# You made a change that needs to be committed
# The following files have been changed
# (To reset to head, use git reset HEAD)
# WindowsGame1/Player.cs
@
~
~
~

Or something like this at least. Your cursor should be at the very top, if its not, you'll need to move it using the arrow keys.

1. Press the letter i to enter Insert Mode.

2. Type your message: Add player ability to change his color

3. Press the Escape key to exit Insert Mode

4. We now want to save. Type :w (do not forget the : in front of the w) and press enter

5. To exit VIM, type :q (do not forget the : in front of the q) and press enter

Your file will then report to git that you are done writing the commit message and are now ready to commit.

As a final reference, to start VIM with a file(it will be a new file if it doesn't exist yet) type this command:

vi

To difficult?
Yeah I agree, that's why I went in search of a different solution, which I will share with you. Be sure you have dowloaded Notepad++(found here) and type this command in msysgit:

git config --global core.editor "'C:/Program Files (x86)/Notepad++/notepad++.exe' multiInst -notabbar -nosession -noPlugin"

So the git config --global core.editor tells git you want to change the text editor. The 'C:/Program Files (x86)/Notepad++/notepad++.exe' is the location of Notepad++ so it might be different for you. You will have to browse your computer for the Notepad++.exe.

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

Next Post Previous Post
Powered by Blogger