-
Quick commit editing with vim
On Mac OS a and Unix systems Git defaults to using vim as the editor for commits.(I don’t know what the default is on Windows) You can change this, if you like, but for now I’ll just give a couple of tips for using vim — just enough to get by.
When Git needs a message for an action it will bring up vim in view mode. You can move around using the
h(move left),l(move right),k(line up) andj(line down)
But for quick editing, the
ikey will put you in editing mode where you can type and move around as you would for most editors. When you’ve finished press theesckey to get you out of editing mode.
The normal command to save the message and quit is
:wqwhich is bit of a finger twister. An alternative isZZwhich does the same thing, but it’s a much easier key combination to use.A final thing. An empty commit message cancels the commit, (or rebase or tag, or whatever action the message is being added for). So if you change your mind just delete the message (the lines starting with the comment character
#don’t count). A useful way of doing this is to make sure you’re not in insert mode by pressing theesckey and then usingddwhich deletes the whole line.Posted on April 17, 2010 with 4 notes ()
-
dog--training liked this
-
365git posted this
-