Skip to content

Below are some simple methods for exiting vim.

Notifications You must be signed in to change notification settings

tctovsli/how-to-exit-vim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 

Repository files navigation

How to exit vim

Below are some simple methods for exiting vim.

The simple way

Credit: @tomnomnom

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

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 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 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]+')"

About

Below are some simple methods for exiting vim.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published