HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
hakluke
how-to-exit-vim
Developer Tools2019–2026
hakluke / how-to-exit-vim

how-to-exit-vim

Below are some simple methods for exiting vim.

27Distinct people
32Mentions
0Explicit recommenders
7.2KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Below are some simple methods for exiting vim.

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year32 dated mentions

Observed mentions: 2019-09-26 05:12:54 UTC to 2026-03-29 18:56:16 UTC.

0510152019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 2 mentions; 2 submissions, 0 comments20192020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 13 mentions; 3 submissions, 10 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 4 mentions; 3 submissions, 1 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments20222023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 5 mentions; 3 submissions, 2 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 4 mentions; 2 submissions, 2 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC220
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC13310
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC431
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC211
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC532
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC422
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC110
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC101

From the project README

An excerpt from the repository, fetched Nov 13, 2026.

Read the project’s introduction
How to exit vim Below are some simple methods for exiting vim. For real vim (and hacking) tips, follow hakluke and tomnomnom on twitter. The simple way Credit: @tomnomnom :!ps axuw | grep vim | grep -v grep | awk '{print $2}' | xargs kill -9 Video tutorial: The ps-less way Credit: @tomnomnom :!kill -9 $(find /proc -name "cmdline" 2>/dev/null | while read procfile; do if grep -Pa '^vim\x00' "$procfile" &>/dev/null; then echo $procfile; fi; done | awk -F'/' '{print $3}' | sort -u) The ps-less way using status files Credit: @hakluke :!find /proc -name status | while read file; do echo "$file: "; cat $file | grep vim; done | grep -B1 vim | grep -v Name | while read line; do sed 's/^\/proc\///g' | sed 's/\/.*//g'; done | xargs kill -9 The ps-less process tree way Credit: @kpumuk :!grep -P "PPid:\t(\d+)" /proc/$$/status | cut -f2 | xargs kill -9 The first contact way Credit: @caseyjohnellis The lazy pythonic using shell way Credit: @PozziSan python -c "from os import system; system('killall -9 vim')" The pythonic way Credit: @hakluke :py3 import os,signal;from subprocess import check_output;os.kill(int(check_output(["pidof","vim"]).decode ('utf-8')),signal.SIGTERM) The pure perl way :!perl -e 'while(</proc/*>){open($f, "$_/cmdline"); kill 9, substr($_,6) if <$f> =~ m|^vim\x00| }' The Rustacean's way Credit: @wodny Reimplement vim in Rust. Call the project rim. Run rim. Exit rim using a borrowed command, ie. :q!. The lazy rubist using shell way Credit: @rynaro $ ruby -e 'system("killall -9 vim")' The rubist way Credit: @rynaro $ ruby -e 'pid = `pidof vim`; Process.kill(9, pid.to_i)' The Colon-less way Credit: @w181496 In insert mode: <C-R>=system("ps axuw | grep vim | grep -v grep | awk '{print $2}' | xargs kill -9") The remote way Credit: @eur0pa In vi: :%!( key="kill-vi-$RANDOM"; nc -l 8888 | if grep $key; then pgrep '^vi$' | xargs kill; fi; ) & Remotely: $ while true; do curl http://vi-host:8888/kill-vi-$RANDOM; done vi will eventually exit Locally (the cheaty, lazy way, why even bother): $ curl "http://localhost:8888/$(ps aux | grep -E -o 'kill-vi-[0-9]+')" The hardware way Credit: @Jorengarenar Pull the plug out The hardware expert way Use VIMKiller! The most practical physical solution to all your VIM troubles. It only costs 500,000 USD! VIMKiller git The timeout way Credit: @aarongorka Before running vim, make sure to set a timeout: $ timeout 600 vim Never forget to set a timeout again: $ alias vim='timeout 600 vim' Make sure to save regularly. The Russian Roulette timeout way When you want to spice things up a bit: $ timeout $RANDOM vim The Shoot First, Ask Questions Later way Credit: @aliva $ ps axuw | awk '{print $2}' | grep -v PID | shuf -n 1 | sudo kill -9 The "all against the odds" Russian Roulette way Credit: @cfrost When you want to spice things up a bit more: :!ps axuw | sort -R | head -1 | awk '{print $2}' | xargs kill -9 The physics way Credit: @eyemyth Accumulate a sufficient amount of entropy. The reboot way Credit: @tctovsli In vi: :!sudo reboot The using vim against itself way (executing the buffer) Open Vim to empty buffer and type: i:qa!<esc>Y:@"<cr> The AppleScript way Credit: @dbalatero In Mac terminal vi: Replace "iTerm" with your terminal application of choice: :let script="activate application \"iTerm\"\ntell application \"System Events\"\n keystroke \":\"\n keystroke \"q\"\n keystroke \"a\"\n keystroke \"!\"\n key code 36\nend tell" | call writefile(split(script, "\n", 1), '/tmp/exit-vim.scpt', 'b') | !osascript /tmp/exit-vim.scpt The Mac Activity Monitor way Credit: @dbalatero let script="activate application \"Activity Monitor\"\ntell application \"System Events\"\n\tkeystroke \"f\" using {option down, command down}\n\tkeystroke \"vim\"\n\n\ttell process \"Activity Monitor\"\n\t\ttell outline 1 of scroll area 1 of window 1\n\t\t\tselect row 1\n\n\t\t\tkeystroke \"q\" using {option down, command down}\n\t\t\tkey code 36\n\t\tend tell\n\tend tell\nend tell\n" | call writefile(split(script, "\n", 1), '/tmp/exit-vim.scpt', 'b') | !osascript /tmp/exit-vim.scpt The MacBook Pro Touch Bar way Credit: @IA_Baby46 Touch quit vim text in your touch bar The Mac Terminal way Press ⌘+q > Click Terminate The Passive Way Walk away. The Passive-Aggressive Way !bash -c "💣(){ 💣|💣& };💣" ...then walk away. (n.b. That's a fork bomb, please don't try at home.) The Microsoft Way Credit: @cheezmeister !powershell.exe /c "get-process gvim | stop-process" The C way Credit: @dbalatero :let script=['#define _POSIX_SOURCE', '#include <signal.h>', '', "int main() {", " kill(" . getpid() . ", SIGKILL);", ' return 0;', '}'] | call writefile(script, '/tmp/exit_vim.c', 'b') | execute "!gcc /tmp/exit_vim.c -o /tmp/exit_vim" | execute "! /tmp/exit_vim" The Emacs way Credit: @dbalatero :let command='emacs --batch --eval=''(shell-command "kill -9 ' . getpid() . '")'' --kill' | execute "!" . command The Vim way Credit: @david50407 :let command='vim ''+\\!kill -9 ' . getpid() . ''' +qall -es' | execute "!" . command The Client-Server way Credit: @tartansandal If +clientserver is enabled -- typically the case for the GUI -- you can simply :!gvim --remote-send ':q\!<CR>' The Yolo Way Credit: @ryanc Don't run this, it could break your computer. :!echo b | sudo tee -a /proc/sysrq-trigger The layered Method Credit: @mashuptwice :!python -c "import os ; os.system(\"ssh localhost kill -9 $(pgrep vim >tmpfile && grep -P '\d+' tmpfile | sed 's/\(.*\)/\1/g' | cat && rm tmpfile) \")" Bonus: still stuck if multiple vim instances are running The epileptic Method Credit: @mashuptwice :!timeout 10 yes "Preparing to exit vim. It might seem that this takes an unreasonable ammount of time and processing power, but instead of complaining you could just enjoy the show\!" | lolcat ; pgrep vim | xargs kill -9 May the magnificent colors help you to forget the emotional damage caused by exiting vim! The Abstinence Method Credit: @ryanc $ alias vim=/bin/true The Passive-Aggressive Abstinence Method Credit: @donkoch
Read the full README on GitHub

What Hacker News says

32 sources

Showing the 15 most recent of 32 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.