mirror of
https://github.com/hakluke/how-to-exit-vim.git
synced 2025-05-02 03:36:42 +02:00
31 lines
872 B
Markdown
31 lines
872 B
Markdown
# 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)
|
|
```
|