A decade ago, a programmer asked on Stack Overflow how to exit the decades-old Vim open source text editor, and the question has since become a cultural touchstone of the modern development experience.

Maybe it’s proof that the 50-year-old text editor has retained its popularity — that it’s now part of the shared collective experience of the developer community. (Vim is a 1991 clone of Bill Joy’s vi editor created in 1976, to serve as the visual mode for a line editor called ex. It was included in the initial Berkeley Software Distribution [BSD] Unix, released in 1978 and has been in the Unix/Linux developer’s toolbox ever since.)

But it also speaks to a larger truth, a fond and knowing acknowledgment that mastering Vim requires taking the time to educate yourself on its shortcuts and functionalities. Maybe there’s some secret pride in the fact that as powerful as Vim may be — there is still a learning curve. Getting trapped in Vim in a decades-old text editor remains a common if not universal experience for struggling first-time users.

Basically, it’s an essential function that can’t always be executed in an intuitive way. When you’re typing away in Vim, it won’t accept commands like “q” for quit until you first hit the escape key — and even then, commands like “quit” are preceded by a colon.

A wise Linux greybeard once pointed out to us that Vim is no different than Microsoft Word in that both have two modes. One is a command mode to save files, add formatting, quit the program itself, and such. And there is the edit mode, where you write your code, book proposals, etc. The trick is to learn how to effortlessly toggle between the two.

Yet, so many novice users have gotten tripped on exiting Vim, that the instructions are now displayed prominently on its welcome screen when the software is launched — even before the Help command.

How to exit Vim on VIM welcome screen.png

And typing Ctrl-C twice in Vim now pulls up a hint at the bottom of your screen.

VIM message (bottom of screen) after Cntrl-C twice

But over the years, the difficulty became the affectionate target of some gentle geek satire. Currently, GitHub even shows 77 contributors to a repository titled “How to Exit Vim.” For example, one suggests the best way is to edit your shell’s alias file so that “vim” gets mapped to a command launching vim processes that time out and end after exactly 600 seconds. (“Make sure to save regularly.”)

How to Exit Vim - the Product Manger Way

A 2019 YouTube video shows an even more convoluted solution. It involves suspending the foreground Vim process (using Ctrl-Z), and then pulling up a list of all active processes (using ps ax), grepping for all the processes containing the string vim — while filtering out that grep process (which also contains the string vim) — and then using Awk to format the results so an xargs comand can kill the Vim-running process.

ps ax | grep vim | grep -v grep | awk '{print $1}' | xargs -n1 kill -9
Commenters on the video responded with exaggerated gratitude, with one claiming they’d been trapped in Vim for an entire week, and another adding “Until now I used to press the power button to exit vim”

Recognizing Ourselves

There’s also a joyful thrill of recognition when geeks stumble across reminders of just how common the problem may be.

Ten years ago someone asked “How do I exit Vim?” on Stack Overflow — and in the decade since the question has been upvoted 4,786 times (and bookmarked by Stack Overflow users over a thousand times). Answers to the question have been lovingly maintained and curated over the last 10 years. And while it took almost five years to reach 1 million views, in the five years since it’s received another 1.7 million views — for a total of 2.7 million.

Last week Reddit users couldn’t resist celebrating the 10th anniversary of the question. After the URL to the original question was posted on Reddit’s programming forum, it drew over 5,000 upvotes — and another 660 comments.

Yet mixed in with the comments were some genuine appreciation for Stack Overflow’s answer. “That answer is what in fact made me properly consider Vim ten years ago,” remembered one commenter. “Ten years later, still one of the best accidental software decisions in my CS journey.”

And another commenter felt Vim didn’t deserve its reputation for a steep learning curve, since “it’s sometimes inflicted on innocent users who were just trying to carry out a git commit. I’d bet that that makes up at least half of the views for that question.”

Reddit programming forum celebrates Exiting Vim question's 10th anniversary.

The question received a special acknowledgment in May of 2017 on Stack Overflow’s blog — when it achieved a special milestone. “You’re not alone…” wrote Stack Overflow data scientist David Robinson. In the five years since this question was asked, there have been over a million other developers who got stuck in Vim and couldn’t escape without a bit of help.” That actually accounted for one out of every 20,000 visits to Stack Overflow’s questions.

“That means during peak traffic hours on weekdays, there are about 80 people per hour that need help getting out of Vim.”

The Demographics of Getting Stuck in Vim

Robinson also couldn’t help acknowledging that the question itself has now attained rarefied status as a techie meme.

But the post also delved into the demographics of those million views (“in honor of this milestone”). Interestingly, in 2017 the country where visits to question represented the highest percentage of all Vim-related question visits was Ukraine (followed by Turkey, Indonesia, Pakistan, Vietnam — and then Russia). The United States ranked #21 (behind Australia, and just above India).

Robinson also calculated the top visitors by which area of Stack Overflow they visited most frequently (based on the area’s tags), hoping to break down Vim exiters by their “main programming technology”. The results? “The developers who are most likely to get stuck in Vim are frontend web developers: those who primarily visit tags like JQuery, CSS, and AngularJS. They’re followed by Microsoft developers (C# and SQL Server) and mobile (Android and iOS).”

The post speculates Microsoft developers usually work with a full-fledged IDE, and may not be as familiar with simple text editors like Vim. In contrast, the developers least likely to get stuck in Vim were those whose main programming language was C, C++, Python or Ruby — languages which Stack Overflow’s data scientist believes are often written with plain text editors.

But the demographics don’t fully dispel the idea that it’s a pretty common experience to get trapped in Vim. And the jokes keep on coming — bearing testimony to that unique yet potentially confounding experience that can await first-time users of Vim.

Amazon’s Kindle Store features a humorous 23-page ebook on the subject — which the author has broken up into 19 chapters. (“Finally, a way to unlock the mysteries of quitting Vim without leaving a trail of destruction behind you.”) Its top-rated review calls it “A Masterful Feat of Concision,” and awarded the 23-page ebook a full five stars, in a possibly-sarcastic review.) “This book is an exhaustive treatise on one of Vim’s most common and least understood features, but it reads quickly and effortlessly. It will stand the test of time.”

Another reviewer tucked mock enthusiasm into their review’s title. “Exited Vim first try. Would buy again.”

And another joked, “I can’t wait for the second edition on how to access and use vim help.”

But alas, one reviewer awarded only four stars. “I would give this book 5 stars but I can’t figure out how to close it.”


Feature image via Reddit.