I'm on a Mac running OS X v10.6 (Snow Leopard). I have Mercurial 1.1 installed.
After I hit Esc to exit insert mode I can't figure out how to save and quit. Hitting Ctrl + C shows me instructions that say typing "quit" will write and quit, but it doesn't seem to work.
The command to save a file in Vim and quit the editor is :wq . To save the file and exit the editor simultaneously, press Esc to switch to normal mode, type :wq and hit Enter .
Other ways to exit Vim Esc + :x + Enter (Save and exit) Esc + :qa + Enter (Quit all open files) Esc + Shift ZZ (Save and exit) Esc + Shift ZQ (Exit without saving)
:q[uit]
quits.
:w[rite]
saves.
:wq
is a shortcut for both
:!command
runs a command in a shell (you could use this to commit without having to leave Vim)
It's also useful to know that
:q!
exits vi without saving, and Mercurial interprets that as you abandoning the checkin. This can be useful if you're editing the commit message and suddenly realise there's something else you need to do.
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