I’m not a Vim user. Nothing against those who do (I’m an editor pluralist), but it’s not my cup of tea.
However, I do like using it for Git. Of course I could use any other editor, or a GUI. But it’s so nice writing a commit or doing a rebase in the terminal in seconds.
If you’re like me (or could be), here’s all the Vim commands I’ve found useful for working with Git. Let me know yours in the comments.
i - go into insert mode, where you can type stuff, such as commit messages.
Escape - escape insert mode. Gets out of insert mode so you can run other commands (including all of the following).
:wq - save and quit. Use this to exit and continue on with whatever git operation you’re doing (commit, rebase, etc).
:cq - quit with an error. Exit, without saving, with an error code. Useful if you messed something up in the middle of an operation, and want to abort the whole thing and start over.
dd - yank (AKA, copy) an entire line.
Shift-p - paste the entire line you just yanked. Useful for re-ordering lines during an interactive rebase.
Bonus tip - add this to your .zshrc
subedit() {
EDITOR="subl -n -w" "$@"
}
Then you can do something like `subedit git rebase -i …`, and temporarily use Sublime Text as the editor instead of Vim.
I use this less for Git, and more for sops.
Anyway, what’s missing from this list?