I once walked up to the computer of a colleague new to linux. He know how to exit, but he didn’t know how not to exit. Every single time he needed to save he did a :wq and then re-opened the file.
TLDR for posterity: type esc like 4 times just to be sure, then colon then letter q (to quit without saving) or the letters qw (to quit and write/save the data) and then hit enter.
How about something Deep Vim like: digraph inside the expression register inside Ex inside Insert (to get here: i<Ctrl-O>gQ<Ctrl-R>=<Ctrl-K>)? From here hitting escape n times doesn’t work.
A sequence of commands that works no matter where you are in that stack of modes is something like:
<Esc> exit digraph mode (or do nothing in Ex-Mode or expression-register)
<Ctrl-U><Enter> exit expression register (or execute empty command in Ex-Mode)
<Ctrl-U>vi<Enter> exit Ex-Mode
<Esc>:qa! exit Insert mode and quit
This sequence also works for other modes I tried, like a half-entered command inside Insert-Visual (i<Ctrl-O>vg) – here, pushing v in step 3 gets you back into Insert and then the rest will exit.
I recently discovered that x does the same job as qw. Now I remember q for exit with no changes (or q! as @weaksauce points out), and x for exit-and-save
I use that too, but I think for new people its better for them to learn qw first so they know w is write and q is quit. Like building a vocabulary for vim commands.
And vim tells you to type :quit<enter> when you press Ctrl-C.
(Why not simply exit when Ctrl-C is pressed? Because in vim Ctrl-C is used to abort an operation that’s taking too long, eg. a search over a gigantic file.)
I remember my first time on vim. I couldn’t even exit. I tried typing ctrl-q, alt-q, esc, q, quit, exit, alt-f4, f1, help, smashing the keyboard etc. none of that worked.
How is quitting emacs easier? I remember the first time I tried emacs I had the same problem… impossible to quit. Isn’t quitting emacs: “ctrl-x” followed by “ctrl-c”?
I once walked up to the computer of a colleague new to linux. He know how to exit, but he didn’t know how not to exit. Every single time he needed to save he did a :wq and then re-opened the file.
A coworker once asked me how to exit vim. When I got to her desk, though, she said she had already solved it.
“ZZ?”
“Reboot.”
TLDR for posterity: type esc like 4 times just to be sure, then colon then letter q (to quit without saving) or the letters qw (to quit and write/save the data) and then hit enter.
if you’re in crazy mode you might need a double
:q(or:qfollowed by:q!)Vim mode (anti-)golf!
How about something Deep Vim like: digraph inside the expression register inside Ex inside Insert (to get here:
i<Ctrl-O>gQ<Ctrl-R>=<Ctrl-K>)? From here hitting escape n times doesn’t work.A sequence of commands that works no matter where you are in that stack of modes is something like:
<Esc>exit digraph mode (or do nothing in Ex-Mode or expression-register)<Ctrl-U><Enter>exit expression register (or execute empty command in Ex-Mode)<Ctrl-U>vi<Enter>exit Ex-Mode<Esc>:qa!exit Insert mode and quitThis sequence also works for other modes I tried, like a half-entered command inside Insert-Visual (
i<Ctrl-O>vg) – here, pushing v in step 3 gets you back into Insert and then the rest will exit.for posterity: it’s actually
:q!if you made changes and you want to exit without saving.Nope. If you already in insert mode you can :q! until you blue in the face.
esc :q!
usually saves the day.
I recently discovered that
xdoes the same job asqw. Now I rememberqfor exit with no changes (orq!as @weaksauce points out), andxfor exit-and-saveI use that too, but I think for new people its better for them to learn qw first so they know w is write and q is quit. Like building a vocabulary for vim commands.
I have the same problem with nano - give me vi any day :~)
nano displays the shortcut to exit at the bottom (provided you know what keys ^X are)
And vim tells you to type
:quit<enter>when you press Ctrl-C.(Why not simply exit when Ctrl-C is pressed? Because in vim Ctrl-C is used to abort an operation that’s taking too long, eg. a search over a gigantic file.)
ZZfor terseness sake? (two keypresses rather than three ;)Isn’t that still three, because shift? :)
Well yeah but it still occurs over the space of two key presses since its a combo. Besides :q is four by that definition
I remember my first time on vim. I couldn’t even exit. I tried typing ctrl-q, alt-q, esc, q, quit, exit, alt-f4, f1, help, smashing the keyboard etc. none of that worked.
And that’s why I’m an emacs user.
How is quitting emacs easier? I remember the first time I tried emacs I had the same problem… impossible to quit. Isn’t quitting emacs: “ctrl-x” followed by “ctrl-c”?