
How to Exit Vim - justinzollars
https://github.com/hakluke/how-to-exit-vim/blob/master/README.md
======
Diederich
I first gained access to a UNIXish system in the fall of 1988, which was some
SunOS4.x variant I believe. The shell was csh, the editor was vi, and I had no
idea what I was doing, nor was there any help in my immediate area to be
found. And no, I didn't know about 'man' yet.

Somehow I discovered that 'vi' was the way to edit things, but I didn't know
how to exit, so trial and error led me to pressing control and z at the same
time. Bingo! The shell is back.

After some days of building up background suspended vi instances, the system
administrator came in and gave me a few pointers.

~~~
downerending
Similar experience, except a ATT 3B2 (and thus no job control). I would have
read the man page, but there were none, nor were any books available.

I finally just pulled the plug out of the wall.

It's not much of an exaggeration to say that I became a lifelong emacs user
because the start screen even back then explained how to exit.

~~~
Diederich
Holy shit, ATT 3B2, I haven't heard any mention of those in a long time.

So, six years later, in 1994, I found myself as the UNIX system administrator
for a large (at the time) datacenter at Keesler Regional Medical Center,
Keesler AFB, Biloxi Mississippi, where we had quite a number of 3B2s. They
were, in fact, the only machines we had that were rated for classified data.

If memory serves, they ran AT&T System V release 3 UNIX.

We also had, among others, DGUX, SCO, AOS/VS, Sun and Vax/VMS servers. Of
course each of AOS/VS and VMS had their own, non-UNIX operating systems.

Funny story: we put word out to AETC (Air Education and Training Command) that
we needed more 3B2s, and a few months later, some pallets arrived from
Homestead Air Force Base, which had been destroyed by hurricane Andrew a
couple of years prior. These servers had green and brown smears on them.
Clearly they had been submerged by hurricane flooding for some period of time.
So we ran a long extension cord out to the parking lot, plugged them in and
stepped back. Much to our surprise, several of them actually worked, and later
ended up racked in our datacenter.

~~~
jes
For what it's worth, I also used DG/UX, MV/UX and AOS/VS on Data General
equipment (MV/10000, MV/4000) at the University of Washington in the 1985ish
time-frame.

I remember porting many BSD 4.x utilities to MV/UX. What a learning
experience, with the MVs differently-formatted byte vs. word pointers.

The C compiler was really nice, though.

Fun times.

~~~
Diederich
You might be the first person I've run into that has heard of AOS/VS. I've run
into one other person over the years that has heard of DG/UX.

Good times indeed.

~~~
coolgeek
My first Unix experience (~1993) was in a heterogeneous shop doing electronic
pre-presss.

SunOS 3.5 on OEM PDP-11s. SunOS4.1.4 on SPARC Stations. SunOS5 (Solaris) on
SPARC Stations. DG/UX on a pizza box. SCO on (I think) a 386

------
yason
In the opposing vein, as an Emacs user the best configuration I ever made was
to rebind C-x C-c to execute-extended-command instead of kill-emacs. It was
_way too easy_ to (even accidentally!) kill emacs with a sweep of a finger.
And I probably use a few hundred execute-extended-command calls for each kill-
emacs (which I now have to type manually as 'C-x C-c kill-emacs' \- no
problemo).

A similar optimisation was with tmux to bind the prefix to C-z. It's in a
handy location next to ctrl and I very rarely use suspend anyway (which is
still available as easily as C-z z). Stretching your fingers between ctrl and
b (the default prefix key) merely made me wonder who the heck thought of
something like _this_?

As for vi, I made a point of learning to use it enough to do useful work
editing config files and small texts. Every once in a while another
application brought up 'vi' for some reason (maybe I lost VISUAL or EDITOR
while sudoing or the app was looking for another variable) and I could never
exit the damn thing.

So instead of just learning :q and figuring out how to make the particular
program or script relaunch another editor I thought it's the path of least
resistance to just edit with vi directly. It has been an incredibly handy
skill: I never use vi for anything larger but these days I actually do 'vi
/etc/fstab' myself instead of calling for emacsclient.

However, I've been toying around with the idea of eventually writing a minimal
'vi' clone that you _cannot_ exit. I'm sure there's pent-up demand just
waiting for one!

~~~
e12e
> A similar optimisation was with tmux to bind the prefix to C-z. It's in a
> handy location next to ctrl and I very rarely use suspend anyway.

I think gnu screen has the right idea here: ctrl-a.

And you say z is close to control - does that mean you use emacs without shift
lock as control?! (I mean sure, still closer than b...).

~~~
smabie
C-a is the worst default keybinding ever, since like, going to the beginning
of a line is one of the most common operations.

~~~
ak217
In the rest of the universe, going to the beginning/end of the line is mapped
to the Home/End keys (fn+left/fn+right on Macs), and I do prefer it when my
thing does things in ways that roughly correspond to how the rest of the
universe does them if there's no compelling reason to do otherwise.

~~~
eitland
> (fn+left/fn+right on Macs)

When I used Mac in 2009 to 2012 it depended on the application you were using:

Some used fn+left/fn+right, some used CMD+left/CMD+right and I think ctrl
and/or alt + arrow keys were an option too.

ctrl a/ctrl e would work everywhere I think but I didn't use those as they
didn't work with shift to select to the start or end of the line.

As a keyboard type of person this was a major part of what drove me away from
Mac despite its many advantages :-(

------
namelosw
\- So, how did you learn Vim? I heard there's quite a learning curve.

\- I just open it, but I couldn't figure out how to quit. Then I have been
using it for three years already.

(Same applies to Emacs.)

~~~
kburman
I have tried to start using vim so many times and failed. Even this year I
thought to start using vim. Daily I open vim once try to do something new with
it. Although I don't have much of hope that I will start using it an soon.

~~~
Grimm665
As a sysadmin, not a programmer, what I found helpful for learning Vim was not
to try something new each day, but to find one or two commands that were
valuable enough that I would at least open Vim somewhat regularly. The two
that did it for me are delete line (dd), and change inner word (ciw), both
extremely helpful for config file editing, especially when combined with
repeat command (.)

After learning these first simple commands, it was enough to get me to open
Vim at least a few times a day, which then motivated me to start learning more
of the commands and it just snowballed along. I still only know probably 25%
of Vim, but I feel incredibly comfortable in it now and rarely run into
trouble when doing beginner to intermediate editing tasks.

~~~
chupasaurus
As a fellow sysadmin, I would advise to learn vi properly then switch to Vim
because the former is pretty much everywhere, and for example you could mess
the file with cursor keys in Insert mode instead of using hjkl in it.

~~~
Grimm665
That's good advice, but in all practical situations I have been able to use
Vim directly or know enough vi to get by, though I am much less comfortable
with it.

I don't touch type, so hjkl, even though I understand the benefits, has never
been my preference. Perhaps it's the gamer in me, I've never had trouble using
the arrow keys :)

~~~
kburman
As far as I know, hjkl was first introduced in games and later used in vim
because we don't have to move our hands far away from the keys.

Feel free to correct me If I'm wrong.

~~~
thegeekpirate
[https://catonmat.net/why-vim-uses-hjkl-as-arrow-
keys](https://catonmat.net/why-vim-uses-hjkl-as-arrow-keys)

~~~
dllthomas
One neat thing this misses is that in ASCII, H is left, CTRL-H is backspace
(which goes left while doing a thing); J is down, CTRL-J is linefeed (which
goes down while doing a thing, sorta). It ends there, unfortunately - I don't
see a good connection between vertical tab and up or formfeed and right.

------
smcl
It's amazing to think how far we've come since June 2018 where the record was
just shy of three minutes
([https://www.youtube.com/watch?v=TLbfqZBL8t8](https://www.youtube.com/watch?v=TLbfqZBL8t8)).
These new strategies could allow experienced speedrunners to exit vim in times
of 10 seconds (or perhaps less!?). I'm excited to see how this progresses, the
vim speedrun community is vibrant and creative and I've no doubt we'll see a
sub 5-second run within my lifetime.

~~~
Dowwie
I believe the solution to this lies in using Rust and SIMD. It will achieve
both performance and safety.

~~~
bobowzki
I would prefer a functional approach and formal verification so we can know
for sure it will exit.

~~~
Dowwie
But who would support it? While a formally verified functional approach may
satisfy one's doctorate requirements, the author will graduate and move onto
blockchain development, leaving behind an exit-vim code base that no other
engineer could possibly understand without the equivalent training. Upon
receiving said training, an engineer would also take newly acquired doctorate
and also move onto blockchain development. Essentially, supporting a formally
verified functional approach to exiting Vim creates a pipeline of well-
credentialed and rigorously trained professionals for blockchain development.
If Vim were, however, put on the blockchain, we may be able to address this
concern and you can get what you wanted.

Or, you could have just used Rust and SIMD.

~~~
dt5702
This hits so close to home.

------
brutt
First step to quit vim is to accept that you are vim user.

Here are some tips:

Try to limit yourself to one vim session per day, then one session per week,
and so on.

Try to replace some Vim sessions with Emacs.

Buy notebook with keyboard without Esc key.

Install an OS without Vim.

Use mouse.

~~~
joncp
> use mouse

Noooooo! Not that! Please not that!

~~~
JdeBP
Why not? It works with VIM and NeoVIM. (-:

------
joeraut
One of my Computer Science lecturers had a rule: use Vim for all development
for his class whilst on campus, and if caught using any other editor/IDE – or
committing any artifacts showing evidence of such – we would lose several
percentage points from our final mark for his class.

Harsh? Perhaps. But I can’t thank that lecturer enough for that rule. He
converted a mostly IDE-wielding class into one that actually appreciated Vim,
and most of us still use it or its key bindings.

Edit: this was in 2018, when VS Code, _etc._ were already popular.

~~~
ChrisRR
That's stupid and elitist. There's no reason to force students to go against
IDEs that they're already used to, but also the general method of navigating
around a computer which they're probably used to from MS Word etc.

~~~
OkGoDoIt
It’s a college class in which students are supposed to learn something new,
that seems like a perfect example of a situation where you should be forced to
do something outside your comfort zone.

I don’t interpret that as the college professor saying this is actually the
best way to code, just that forcing students to struggle through it is a
learning experience.

~~~
dragonwriter
> It’s a college class in which students are supposed to learn something new

Unless the central thrust of the course is supposed to be the mechanics of a
particular dated editor, the restriction described seems to be a distraction
from rather than an aid to what the students are supposed to be learning.

It doesn't make any more sense than a social science course where the
deliverables for most assignments are essays mandating WordPerfect for DOS.
Sure, you'll learn something you might not otherwise, but it's a distraction
from what you came to the course to learn.

~~~
Seirdy
> particular dated editor

I wonder how you feel about age discrimination. Old != bad.

I started using Vim when I was 14; I was the only one in the class who wasn't
using an IDE. Vim (perhaps combined with a language server if you're okay with
the complexity) runs circles around bloated IDEs like IntelliJ/VSCode. Unix
combined with a tiling WM is the best IDE in existence.

The professor in question is likely doing the students a service by showing
them the advantages of minimalism and function-over-form over the trend of
bundling an OS with every "app". Many students today only feel comfortable
using software that saturates their synapses with colors and animations;
having to use Vim for a semester forces the good ones to realize that maybe,
just maybe, function should come before form. Maybe 10k lines of C or POSIX
shell solves a problem better than a VC-backed Electron app.

To continue your analogy, WordPerfect and DOS, unlike Vim, aren't better than
today's tools. What _would_ be an improvement is LaTeX/BibTeX for writing
essays. Once I realized how much work was automatically done for me--from
Chicago-style footnotes/endnotes and auto-generated ToC from headings, the
time I spent formatting my papers dropped to zero. I would absolutely
incentivize students to use these tools over "modern", bloated word
processors.

~~~
saagarjha
Cool, I use nano. Should I be penalized?

~~~
Seirdy
Minimalism for the sake of minimalism isn't what I was arguing for. If it
were, I'd say that every paper and program should be written with `ed`, the
standard text editor [0].

What I _was_ trying to say was that if minimal solutions run circles around
bloated ones thousands of times their size, and when it takes a startup and
two funding rounds to develop something that does exactly what tools did three
decades ago _less efficiently_ , then maybe Braithwaite was on to something:

> “It’s a curious thing about our industry: not only do we not learn from our
> mistakes, we also don’t learn from our successes.” -- Keith Braithwaite

[0]: [https://www.gnu.org/fun/jokes/ed-
msg.html](https://www.gnu.org/fun/jokes/ed-msg.html)

------
talles
Jokes aside, shouldn't the page start with actually teaching how to quit vim?

The page is considerably popular to show up on a Google search. I imagine the
frustration of a beginner actually trying the first examples and not getting
the joke immediately.

~~~
Lio
Yeah, I mean if you really wanted to help people exit Vim you'd trap Ctrl-c in
command mode and print the instructions at the bottom of the screen.

Something along the lines of "Type :qa and press <Enter> to exit Vim" would
probably do it...

~~~
Kye
This kind of advice confused me early on because I didn't realize the : was
part of the command for way too long. For beginners, you might want to spell
it out further as: "shift and the : key, then qa, then Enter"

~~~
Lio
I think that's a great suggestion and probably gets the root of the whole exit
vim meme.

~~~
nj65537
I don't have a qa key though

~~~
Lio
I’ll laugh about this now but then probably find out later that it was
actually based on an obscure teletype terminal that actually had an “qa” key.

------
weinzierl
The question is not _" How"_ but _" Why"_ you would want to ever do that in
the first place;-)

Many years ago I knew a university professor and students said about him he
might leave uni occasionally but he sure never leaves Emacs. Some live in
Emacs, some live in Vim.

~~~
cmroanirgo
I live in a different universe to you it seems. The _only_ vim command I know
is _:q_.

Honestly, I tried several times over the decades and walked away with my head
buzzing.

PS: I don't live in emacs either!

What I _do_ love in both camps is how the explanations begin... "All you have
to do is...[insert irrational (to non-vim/emacs users) command]" which makes
me laugh every time.

Love the article, which ironically proves my stance of me keeping well clear.

~~~
Cthulhu_
I know some basic commands and know it well enough to edit git commit messages
and interactive rebase (`ddkP` is probably the most advanced command I know).
But I've never thought "I prefer this over my regular editor this is amazing".
I just don't get the satisfaction.

And of course I'd have to dive deep into the ecosystem in order to get the
same benefits that my main editor provides out of the box, like idk, cmd+click
to go to definition, or error reporting like squiggly red lines.

~~~
yodsanklai
> And of course I'd have to dive deep into the ecosystem in order to get the
> same benefits that my main editor provides out of the box,

To me, vim shines as a _modal editor_ , not an IDE. I use it for two purpose:

1\. quick editing configuration files, or single file scripts 2\. an editing
mode in an IDE (mostly VSCode)

The main benefit of vim is to save you from using the mouse or the touch pad.
I touch type, my indexes rest on F and J, and I can do pretty much anything
without leaving the keyboard, without using the arrow keys, and keeping my
eyes on the screen. It's not something I'd know how to do without Vim. If I'm
using the arrow keys, I need extra-time to relocate the "J" key, which breaks
the typing flow.

~~~
ramraj07
My hypothesis is that vim style work (without moving a wrist even a bit) is
the reason people get carpel tunnel. I anecdotally see far fewer (none?)
People who don't do vim/emacs getting these injuries. Makes sense as well
right? Just like "take a walk and don't sit in the same place" but for your
fingers

~~~
ezzzzz
I don't know about carpel tunnel, but the reason I became interested in
Vim/Emacs was due to RSI caused by using a mouse. This was my first job, doing
_shudders_ Java-EE (7) web development (no live re-loading, tons of clicking
in IDE, manually reloading web-page etc, crappy windows touch-pad etc).

Started learning Rails, drank the Kool-Aid, switched to VIM. I don't use VIM
for development at my day-job, mostly just key-bindings in Intellij/VS Code,
however, the amount of time saved has been worth the effort, and no RSI (also
thankfully am able to use the fantastic track-pad on mac and a trackball for
anything else).

Lately I've been feeling the pull to learn Emacs after learning about ORG-Mode
and the extensibility of the software... unfortunately, the time investment
here is likely to have no real benefit in my (current) work as a Java dev.
_Sigh_ , time to browse the who's hiring thread.

------
rsecora
As the old joke says[1].

    
    
      ED(1)               Unix Programmer's Manual                
    
      NAME
         ed - text editor
    
      SYNOPSIS
         ed [ - ] [ -x ] [ name ]
    
      DESCRIPTION
         Ed is the standard text editor.
    
    
    

[1] [https://www.gnu.org/fun/jokes/ed-
msg.html](https://www.gnu.org/fun/jokes/ed-msg.html)

~~~
rhinoceraptor
I've written the following one-liner if ed(1) is unavailable on your system,
to emulate its functionality:

    
    
        trap 'echo -e "\n?"' INT; while true; do read; echo "?"; done

~~~
rsecora
:), Yeah, those were the days!

------
SilasX
Very clever, but I wish they would put the real way, which, for the record, is

    
    
        :q
    

at the top so that this doesn't annoy people who legitimately google it and
have to wade through this.

~~~
artursapek
But any of the other methods work just as well

~~~
SilasX
Not by the metrics "tediousness" and "applicability to later vim usage".

------
gpmcadam
Oh dear. What are the chances this will eventually rank fairly highly on
search engines - this is going to ruin the soul of the unsuspecting people who
end up thinking that this is not satirical advice.

~~~
Zenst
Better they ruin their own soul than inflict upon others is the way to look at
that.

But then, what type of people don't RTFM besides the whole generation that
treat google as their manual and when the internets down, so is there
`knowledge` /s.

~~~
cerebellum42
RTFM clearly does not apply because you can't read it if you're in vim and
can't exit ;)

~~~
Zenst
:h or failing that, the tried and trusted :!man vim

Though I'm wondering how many have discovered the first one with some frantic
help me after typing the : and got there by accident.

Oh you can apparently just hit F1 in vim, wow.

------
kerkeslager
As a senior dev, I wanted to pat myself on the back and say

    
    
       :q
    

But then I realized that the senior dev way is more like:

1\. Look it up on Stack Overflow.

2\. Send the Stack Oveflow to the intern and tell intern to do it.

3\. Reject the PR because it lacks unit tests.

4\. Reject the PR because it didn't account for an obscure case that product
usually is concerned about.

5\. Reject the PR because it there's a simpler way to do it.

6\. Pair program with the intern because they're having trouble.

7\. Realize that tests are a bit overkill, the obscure case can't happen, and
the complexity is because of trying to make it testable and handling the
obscure case.

8\. Merge a PR that looks suspiciously like what the intern originally
submitted.

9\. When QA rejects, send back to QA asking for steps to reproduce (har har).

10\. When QA sends back steps to reproduce, send back saying you can't
reproduce (har har).

11\. Sit with QA and see that the bug exists, because they doing something you
didn't think of.

12\. Fix the bug, merge the code.

13\. When the manager asks you to, create the story in Pivotal and push it
through all the states (everything so far happened in Slack).

14\. Years later, come across the same problem at a different company, and
notice someone `:q` in one of the side comments on Stack Overflow, which was
there the last time you looked, you didn't notice it.

------
reacweb
I do not like the grep -v grep pattern. I think the regexp trick should be
prefered:

    
    
        :!ps axuw | grep [v]im | awk '{print $2}' | xargs kill -9
    

This can also be merged in the awk command:

    
    
        :!ps axuw | awk '/[v]im/{print $2}' | xargs kill -9

~~~
wadkar
Ugh, ps|grep is unnecessary. Just use pgrep! Or even better, pkill -9 ;-)

~~~
cptnapalm
I started using Linux in 1997 and just today I've found out about pgrep and,
on reddit, sudo !!

What a day!

~~~
wadkar
Wow! Glad to be part of your journey in discovering linux.

I have been amazed by linux since my teenager years and it still has so much
more to offer.

May we be blessed to be amazed for the eternities of our mortal lives.

~~~
cptnapalm
The UNIX ecosystem (digisystem?) always has more to find.

Also, your reply is the kindest comment I've ever seen on HN.

------
brazzledazzle
I distinctly remember being a teenager and trying vim. Being entirely confused
I wanted to exit and when I realized I couldn't I panicked a bit and started
smashing keys. Eventually I gave up and forced a reboot with the power button.
Based on my extensive experience with Windows I was confident it was hung in a
bad state.

------
yoz-y
I came into this with a sense of "oh not again" and came out surprisingly
happy. TIL that ZZ, ZQ exist and that a disown command exist on the command
line.

Also my preferred method from the list is the timeout, it would be nice to
have counter in a corner of the vim window to know how much time is left
though.

~~~
mewpmewp2
What I do is I set a 25 min timeout, so not only it exits vim it also acts as
a Pomodoro timer for me. Two birds, one stone.

------
numlock86
I was on a remote system and remember I couldn't exit vi. What did I do? Well,
I opened a second ssh session, looked up the process id with ps and killed it.

This is so many decades ago ... like the very beginning of my curiosity when
it comes to IT basically. Thinking back to it, I wonder how I was able to use
ssh and tools like grep, ps and kill but did not know how to operate basic vi
...

~~~
noxToken
> _Thinking back to it, I wonder how I was able to use ssh and tools like
> grep, ps and kill but did not know how to operate basic vi ..._

This has become a recurring thing for me to the point where I sometimes feel
like I'm not as intelligent as I used to be. I'll need to look at requirements
around older existing code, so I use git blame to see the commit history. It
occasionally leads to me to some older code that I had written, and sometimes
I marvel at how I was able to figure out or troubleshoot the issue.

One of the earliest examples in my professional career is using Threads. I had
an academic understanding of threads. My practical knowledge around them was
dubious at best. With the help of Stack Overflow and lots of web searching, I
cobbled together a thread manager that can spawn separate threads for
asynchronous web requests and kill a web request after X amount of time. I
even made sure that error handling redirected gracefully should one of those
threads get killed. That code (with no changes to the core functionality)
still exists to this day.

------
NalNezumi
They forgot the Freshman CS student way: Panic, Lock the computer in the
computer room, run.

~~~
vermilingua
Send a PR!

------
orang55
This is as good of a place as any to mention that I built
[https://howtoquitvim.com](https://howtoquitvim.com) a while back if you need
a less-sadistic reminder for how to exit Everybody's Favorite Text Editor.

------
thepete2
I have the feeling something is missing on that list, but I can't put my
finger on it ...

~~~
Zenst
BRS, that old classic Big Red Switch, kills all known operating systems and
proc's, dead in their tracks.

Me, It's usually :wq, or sometimes :q! or more than likely ZZ - which can be
done with shift zz or if you truly want to do it with just one finger,
capslock then zz.

~~~
xerox13ster
:x

~~~
epr
Thank you. I swear every time I see a tutorial where someone is using vim they
say to save and close with :wq and it drives me nuts.

~~~
Zenst
That is because it is easier to teach as x you will associate with exit,
though wq is write quite, but more so if you just want to save without exit
you logically understand to just use w and from that you start to think -
could I do :q, why yes you can if nothing changed and if so it will tell you.

But stressing how people exit vi is like stressing about people's fashion,
just not worth it. If anything, have a private laugh at them to yourself and
use that to remove other stress as more than enough stress in life, more so IT
without seeking it out.

------
lelf
If exiting vim is too easy, try the advanced level: exiting "vim -y".

~~~
Lio
Try Ctrl-o followed by :q!

That should do it. ;)

Ctrl-o moves from INSERT mode to COMMAND mode for one command and so it still
works in "easy" mode. I notice that "easy" mode was one of the things that the
Nvim guys removed.

------
scanr
I like

:x

which effectively does an :wq if there have been changes but is one character
less.

~~~
tgv
ZZ

------
acje
From the readme: "Remotely:

$ while true; do curl [http://vi-host:8888/kill-vi-$RANDOM;](http://vi-
host:8888/kill-vi-$RANDOM;) done vi will eventually exit"

Bold claim, and how would you know? What if there is a network partition
preventing you from getting the message that exiting vi failed and Chuck
Norris?

~~~
jrumbut
Ah, the famous CEVP Theorem (Consistently Exiting Vim under Partition).

Almost as important a problem in Computer Science as P!=:WQ.

------
shrimpx
I got one: stop paying the electric bill.

~~~
teekert
I just installed a Kasa TP-Link smart plug, now I can kill Vim from an app!

------
jerzyt
Interestingly, deleting the vim executable won't exit, because Unix has the
"funny" habit of keeping a file handle alive as long as it's referenced by a
process. Really cool way to mess with some noobs.

~~~
samatman
What is the 'deleting an executable' you speak of?

All I know how to do is remove a reference to a file, and hope it's the last
one and that Unix will garbage collect it eventually.

Remember kids: `rm` is just `ln` backwards.

------
dreamcompiler
After I invent time travel I'm going to mail my 30-years-ago self a T-shirt
that says "Colon Q Bang" on the front and "You're Welcome" on the back. It
will save myself much anguish.

------
joantune
I can't wait for this article to be on top of Google's search results for 'how
to exit vim' = D

------
franze
The Scrum manager way

1\. Call in a meeting, early in the morning

2\. Tell everybody what a good job they are doing.

3\. Tell everybody that there is still a lot to do.

4\. Tell everybody that "we" can do it.

5\. Remind them of the importance of team work.

6\. Go through the tickets.

7\. Tell the project manager that a ticket for closing Vim is missing.

8\. Write a ticket called "As a user I want to exit Vim!" on your own.

8.1. While reminding everybody that this is not the proper process.

9\. Discuss new ticket in group.

10\. Reword ticket as "As a user I want to be able to open other
applications!"

11\. Ask who of the team wants to do this.

12\. Postpone decision until the next meeting.

~~~
time0ut
There is a step somewhere in there where we waste 30 minutes playing "agile
poker" and arguing about the number of story points required to close vim.

The whole thing is followed up with a two hour retrospective where we pat
ourselves on the back for increasing velocity (due to assigning story points
to closing vim).

Bonus points if you then are asked to map that back to actual hours so we can
estimate completely unrelated future tasks while simultaneously remembering
that we don't estimate in hours.

~~~
Rooster61
You forgot the conversation on the way back from the retrospective about how
velocity is a bullshit indicator of actual productivity and we aren't doing
agile correctly at this company.

------
oefrha
As an Emacs user I just realized to my horror that I know the command(s) to
exit vim but not the one(s) to exit Emacs. I can only tell you it begins with
C-x. (Of course, my left hand knows.)

~~~
topologistics
Sometimes your right brain doesn't have to know what your left hand is doing.

------
tinti
I would love to see a HowToBasic way
([https://en.wikipedia.org/wiki/HowToBasic](https://en.wikipedia.org/wiki/HowToBasic)).

------
jerzyt
I once found a system where a third party vendor installed vim as root with
suid permissions. I've had a few days of fun before I finally decided to clue
the sysadmin about it.

------
longemen3000
In Julia slack, when talking about Julia IDEs, this came. The solution : a
hardware VIM kill switch
[https://github.com/caseykneale/VIMKiller/blob/master/README....](https://github.com/caseykneale/VIMKiller/blob/master/README.md)
I strongly suggest donating the suggested amount to the project

------
jancsika
What about querying how much ram you have and then pasting the letter 'q' that
many times plus one into the buffer?

Edit: perhaps to speed it up: start with a single 'q', selecting all, yank,
and paste. Just script it to repeat until exit happens. No ram query needed.

------
Lex-2008
I like The timeout way :-)

~~~
eoikonomou
Actually the random timeout is even better!

------
lsiebert
As I sit here, vim running for several months inside an nvim terminal inside a
tmux window inside an iterm tab inside mac os x, I think the real question is,
why exit vim yourself when you can Inception vim's creator to do it for you?

That, as many people know, is actually how vim finally became threaded, and
I'm sure it could be used to make a code change that exits vim automatically.
Then you only have the task of modifying your vim executable in memory as well
as on disk, which is so trivial that I leave it as an exercise to the reader.

------
bachmeier
The Russian Roulette timeout way brings back memories of Windows 98.

------
buboard
I just don't understand why anyone would want to exit vim.

------
makach
I thought it was a joke article until I realized it wasn't

------
Johnny555
I'm curious about this one:

    
    
      Don't run this, it could break your computer.
    
      :!echo b | sudo tee -a /proc/sysrq-trigger
    

Why would that break my computer?

Doesn't that just force a reboot without unmounting disks, or about the same
thing that would happen if you pull the power cord (but probably safer, since
anything in a hard drive write cache (or in the middle of being written to an
SSD) will still be written)

~~~
JdeBP
Open issue #46 deals with power cords, and thus: no.

------
tambarskjelve
WARNING: Learning to exit Vim is the number one gateway drug to perpetual
configuration of dotfiles and plugins. The truth is that you can never exit
Vim. NEVER!

------
rushi_agrawal
Didn't see a mention of a very fast way of exiting Vim, so sharing:

'The iTerm way': map cmd-l to send a hex code '0x6A 0x6B 0x3A 0x71 0x0D'
(translates to jk:q<enter>, where jk is my Vim binding to get out of insert
mode)

For me, just like any other touch typer, left thumb is always on cmd and right
ring finger is always on 'l' key, so this arrangement takes least amount of
time for me to quit Vim.

------
astatine
This is a well studied problem from the days of Turing. Named slightly
differently as the Halting Problem, the question of whether Vim will stop for
a given arbitrary input has been proven by Turing
[[https://en.m.wikipedia.org/wiki/Halting_problem](https://en.m.wikipedia.org/wiki/Halting_problem)]
to be unsolvable.

------
DonHopkins
The only vi command I know is :q!

(That and the Rogue navigation keys.)

~~~
mikro2nd
If my ageing memory serves, it was the other way around: Rogue imitated vi for
navigation keys.

~~~
suprfnk
Don't both originate from the fact that (some) early keyboards had the arrow
keys on HJKL?

[https://stackoverflow.com/a/29243081/1891877](https://stackoverflow.com/a/29243081/1891877)

------
m0zg
The funniest one is the "experienced product manager way" IMO. I've seen
plenty of those "experienced project managers" work, and the description is
spot on. It's amazing that such impediment to productivity is even tolerated,
let alone paid handsome amounts of money for. All while the company _thinks_
they're getting better productivity.

------
jrumbut
I used to believe the most important scientific problems have yet to be
solved, but this really was the last great mystery out there.

------
abbadadda
Favorite vim commands:

yy - yank dd - delete and yank O - insert line above o - insert line below GG
- go to bottom of file gg - go to top of file Navigation keys == - auto indent
code block v - visual mode :%s/find/replace/g :set paste :set number :set
nonumber :q - quit :-p

I <3 vim + tmux + iTerm2 + tmuxinator

------
konfusinomicon
What's the best way to generate a random string in 2020??

Tell a room full of comp100 students to save and exit vim :)

------
JdeBP
As before, I'll see all of those and raise you _killing the entire virtual
machine in order to exit nano_.

* [https://unix.stackexchange.com/q/412194/5132](https://unix.stackexchange.com/q/412194/5132)

------
globuous
Fun read! My next bash exercise will be to try and understand some of these
commands, quite a feat! greping the ps output would work with any program,
right ? That was pretty cool. Killing it from emacs was def a good laugh !

They should add the script kiddie way: `sudo rm -rf /` ^^

~~~
inimino
That might delete the executable but the process would still be running.

Yep, `ps | grep` is a common and useful idiom!

~~~
ktpsns
In fact "pkill init" or "kill 0" (each with sudo/root privileges executed)
will most likely kill all processes and is some kind of process equivalent to
delete all files ;-)

------
srik
Atleast this ones a bit amusing. Speaking of amusing, this book on the vim
website -
[https://www.vim.org/images/exiting_vim.jpg](https://www.vim.org/images/exiting_vim.jpg)

------
anaphor
If you use `kill -9` to exit vim, you might find your terminal in a weird
state, because they are most likely using the `atexit` function to reset your
termios settings to normal, but that doesn't happen if you `kill -9` it.

------
bigbaguette
This post is perfect to spot people who comment without reading the source. :q

~~~
JdeBP
Several comments here have merely duplicated old closed issues.

* [https://github.com/hakluke/how-to-exit-vim/issues/14](https://github.com/hakluke/how-to-exit-vim/issues/14)

------
Hitton
Ctrl+z and then kill %1 has yet to fail me. And I'm not talking just vim.

------
antihero
I think this is probably far too nice, but what about

    
    
        pkill vim

~~~
MikusR
That just types ll vim

------
hellofunk
I think the more interesting question is, after you eventually exit vim, what
do you do next?

The best advice I ever received was, you next open emacs and leave the session
running the rest of your life.

~~~
cmarschner
Are you using tabs as well?

------
gingerlime
This is so fun. Reminds me of Nocode[0]

[0]
[https://github.com/kelseyhightower/nocode](https://github.com/kelseyhightower/nocode)

~~~
numlock86
I like this commit:
[https://github.com/kelseyhightower/nocode/commit/80f38e0f103...](https://github.com/kelseyhightower/nocode/commit/80f38e0f103487fc37d853a98a580c67b4db7b55)

------
aasasd
It appears that the first bunch of methods don't account for graphical
distributions of Vim, e.g. MacVim―which have a different executable name.

~~~
JdeBP
I suggest going to [https://github.com/hakluke/how-to-exit-
vim/issues](https://github.com/hakluke/how-to-exit-vim/issues) and filing a
bug report that sometimes one needs to type in a Scottish accent.

------
GavinAnderegg
On a saved buffer, I usually use `Ctrl-w q` (Window command, close). I have
Ctrl mapped to caps lock, so this is super quick to do with one hand.

------
techbio
Just stay in Vim :)

~~~
unkulunkulu
You could send a PR with an “Acceptance way”. Also there’s “Radical acceptance
way”: kill every other process, although I’m from mobile and too lazy to work
out an exact shell command for that

------
tomcam
[https://howtoexitthevimeditor.com/](https://howtoexitthevimeditor.com/)

------
ludwigvan
Easiest way for me is ESC (just to be sure we are not in insert mode),
followed by `ZZ`. (`ZQ` if you don't want to save)

------
wanderr
I know this is a joke but my actual preferred way is :cq so that whatever
thing decided to open vim doesn't proceed. :)

------
29athrowaway
The 1st example could be simpler using pgrep and cut, or simply pkill or
killall.

You can also just suspend it (ctrl+Z), and resume it with fg.

------
kibibyte
I know this is humor, but I never knew about using Ctrl+R (<C-r>) within
insert mode or within an Ex command.

------
metaxy2
Do we know if exiting vim is solvable in all cases, or would that require some
deeper result like solving P = NP?

------
teekert
Just close the terminal window en delete all files starting with ~ in the
directory. Very clean way to stop Vim.

------
cynwoody
I just do ZZ, if I want to save the buffer, or ZQ if I was just looking, or I
messed up (I'm a vim newbie).

~~~
suprfnk
This page is satire. :)

------
smitty1e
I would add a Paul Simon way, loading "50 Ways To Leave Your Lover" until
resources are exhausted.

------
mlang23
The BRLTTY way: 1\. $ echo ZZ | brltty-clip -r 2\. Switch to Vim and invoke
the paste command of BRLTTY.

------
musicale
Aww, the first thing that came to mind for me was pkill -9 vim, which sadly
isn't on the list!

------
just_myles
I was able to find how to exit vim fairly easily. I do like this though it's
quite funny.

------
marc_abonce
I haven't tried any of these, but wouldn't most of them leave the .swp file
there?

------
lenkite
`ZQ` in normal mode exists VIM with no trouble. 2 keystrokes compared to
`:q<Enter>`

------
winrid
Edit - Related in that I used vim and probably won't again:

I recently did an interview where I had to implement something to flatten a
deeply nested structure into a map of path -> value.

The interviewee's had me use VIM. That was my first real dive into it. Solved
the problem, already forget how to use VIM. :)

------
ArcMex
How to exit vim big brain style with all changes saved in memory _.

:q!

_ your memory, not the computer's

------
z92
This one is the shortest way in the list :

The test driven development way

:echom test_null_list()

And it works. Just checked.

~~~
gpvos
Doesn't work for me, just gives an error message "E730: Using List as a
String" and returns me to command mode.

------
gustavorg
That list is incomplete, at least in windows. You always can do ALT-F4

------
0x70dd
Every time I open vim by accident, I have to restart my computer.

------
AnnoyingSwede
I just wish i could upvote this more! :) Love the Jira way!

------
peterwwillis
I am upset that they're using signal 9 instead of 15.

------
zyxzevn
Due to the Stockholm Syndrome people started liking VIM...

------
rygh
Learned shift zz after four years of vimming...shame...

------
indigodaddy
Maybe don’t do the reboot way on Solaris...

------
gowld
Recent versions of vim have a "quick" exit with mnemonic "q":

    
    
        <Esc> :q!

------
al_be_back
one could use emacs instead - it's a sure way to exit vim ... :\ :/

------
svnpenn
Obligatory

[https://github.com/cabellwg/exit-vim](https://github.com/cabellwg/exit-vim)

------
u801e
Next level: how to exit ed.

------
thrwaway69
pssh.. they didn't mention the vimtectualist way - :q!

or the French way - ZZ

~~~
jraph
As a vim noob, I needed to look it up [0]. ZZ saves the current file if
modified and closes it. ZQ closes it without saving. Thank you, that will save
me a few seconds per year.

Why the French way? I don't get it and I am very curious :-)

[0] [https://unix.stackexchange.com/questions/93144/exit-vim-
more...](https://unix.stackexchange.com/questions/93144/exit-vim-more-quickly)

~~~
throwaway744678
(Wild guess) If you pronounce the command aloud - "Zee-zee" \- it translates
to "Willy" (penis word used by children) in French. Easy mnemonic.

~~~
toby-
>Zee-zee

Only if you're American. Otherwise: "zed-zed". :)

------
CloudXperts
Thank you for this..

------
_wldu
Why is :wq so hard?

------
raverbashing
Use nvim, press Ctrl-C and it will show the corresponding help message

~~~
CGamesPlay
It is not necessary to use nvim to see this help message; it's in vim 8.0 that
comes stock with my Mac.

~~~
raverbashing
True, I just checked, though the help message is a bit different

------
kerng
The one thing I remembered from school about vi was:

:q!

Figured that would be useful to know in future.

------
a3n
The Marvel Universe way:

Hulk smash!

------
joeblau

      shift + zz
    

Save and out!

------
Account123481-x
some people have way too much free time.

------
forgotmypw_
^Z

------
SpaceInvader
How about the most basic? ;-) q! wq! x!

;-)

------
chvid
Great jokes but bad user interface design comes at a real cost.

~~~
jmiskovic
From perspective of ASCII-only application, vim interface isn't actually bad,
it just lacks discoverability. There is also a real cost to making tool
beginner-friendly and it often makes sense to optimize for advanced users
instead.

~~~
noisem4ker
An interface lacking discoverability is a bad interface.

~~~
jmiskovic
Once you learn the tool, discoverability wastes screen space and user focus.
It's like training wheels, at some point you want them off or they slow you
down. I'm not a vim user, I just appreciate the UI trade-offs made by its
devs.

~~~
noisem4ker
At that point, you should be able to hide the parts of its interface that you
no longer need. Defaulting to an optimized, non-discoverable setup from the
start is simply a bad idea.

