下面是一些退出vim的简单方法。
有关真正的 vim(和黑客)技巧,请在 Twitter 上关注 hakluke 和 tomnomnom。
信用:@tomnomnom
: ! ps axuw | grep vim | grep - v grep | awk ' {print $2} ' | xargs kill -9
信用:@tomnomnom
: ! kill -9 $ ( find /proc -name "cmdline" 2>/ dev /null | while read procfile; do if grep -Pa '^vimx00' "$procfile" &>/ dev /null; then echo $procfile; fi; done | awk -F'/ ' ' { print $3 }' | sort - u )
信用:@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
信用:@kpumuk
: ! grep - P " PPid: t ( d +) " /proc/ $$ /status | cut - f2 | xargs kill -9
信用:@caseyjohnellis
信用:@PozziSan
python -c " from os import system; system('killall -9 vim') "
信用:@hakluke
: py3 import os , signal ; from subprocess import check_output ; os . kill ( int ( check_output ([ "pidof" , "vim" ]). decode
( 'utf-8' )), signal . SIGTERM )
:!perl -e ' while(</proc/*>){open($f, "$_/cmdline"); kill 9, substr($_,6) if <$f> =~ m|^vimx00| } '
信用:@wodny
rim
。rim
。rim
,即:q!
。 信用:@rynaro
$ ruby -e ' system("killall -9 vim") '
信用:@rynaro
$ ruby -e ' pid = `pidof vim`; Process.kill(9, pid.to_i) '
信用:@w181496
在插入模式下:
<C-R> = system ( " ps axuw | grep vim | grep -v grep | awk '{print $2}' | xargs kill -9 " )
信用:@eur0pa
在vi
中:
: % ! ( key = " kill-vi-$RANDOM " ; nc - l 8888 | if grep $key ; then pgrep ' ^vi$ ' | xargs kill; fi; ) &
远程:
$ while true ; do curl http://vi-host:8888/kill-vi- $RANDOM ; done
vi
最终会退出
本地(欺骗、懒惰的方式,为什么还要麻烦):
$ curl " http://localhost:8888/ $( ps aux | grep -E -o ' kill-vi-[0-9]+ ' ) "
图片来源:@Jorengararar
将插头拔出
使用VIMKiller!解决您所有 VIM 问题的最实用的物理解决方案。只需要 50 万美元!
VIMKiller git
图片来源:@aarongorka
在运行 vim 之前,请确保设置超时:
$ timeout 600 vim
永远不要忘记再次设置超时:
$ alias vim= ' timeout 600 vim '
确保定期保存。
当你想让事情变得有趣一点时:
$ timeout $RANDOM vim
信用:@aliva
$ ps axuw | awk ' {print $2} ' | grep -v PID | shuf -n 1 | sudo kill -9
信用:@cfrost
当你想让事情变得更有趣时:
: ! ps axuw | sort - R | head -1 | awk ' {print $2} ' | xargs kill -9
信用:@eyemyth
积累足够量的熵。
图片来源:@tctovsli 在vi
中:
: ! sudo reboot
打开 Vim 清空缓冲区并输入:
i : qa ! <esc> Y: @" <cr>
图片来源:@dbalatero 在 Mac 终端vi
中:
将“iTerm”替换为您选择的终端应用程序:
:let script = " activate application " iTerm "n tell application " System Events "n keystroke " : "n keystroke " q "n keystroke " a "n keystroke " ! "n key code 36 n end tell " | call writefile(split(script, "n", 1), '/tmp/exit-vim.scpt', 'b') | !osascript / tmp / exit - vim.scpt
信用:@dbalatero
let script = " activate application " Activity Monitor "n tell application " System Events "nt keystroke " f " using {option down, command down} nt keystroke " vim "nnt tell process " Activity Monitor "ntt tell outline 1 of scroll area 1 of window 1 nttt select row 1 nnttt keystroke " q " using {option down, command down} nttt key code 36 ntt end tell nt end tell n end tell n " | call writefile(split(script, "n", 1), '/tmp/exit-vim.scpt', 'b') | !osascript / tmp / exit - vim.scpt
信用:@IA_Baby46
触摸触摸栏中的quit vim
文本
按⌘ + q > 单击Terminate
走开。
! bash -c " ?(){ ?|?& };? "
……然后走开。 (注意,这是一个叉子炸弹,请不要在家尝试。)
信用:@cheezmeister
!powershell.exe /c " get-process gvim | stop-process "
信用:@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 "
信用:@dbalatero
: let command = ' emacs --batch --eval= '' (shell-command "kill -9 ' . getpid () . ' ") '' --kill ' | execute " ! " . command
信用:@david50407
: let command = ' vim '' +\!kill -9 ' . getpid () . ' ' ' +qall -es ' | execute " ! " . command
信用:@tartansandal
如果启用了+clientserver
(通常是 GUI 的情况),您可以简单地
: ! gvim -- remote - send ' :q!<CR> '
信用:@ryanc
不要运行它,它可能会损坏您的计算机。
: ! echo b | sudo tee -a /proc/sysrq-trigger
信用:@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) " ) "
奖励:如果多个 vim 实例正在运行,仍然会卡住
信用:@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
愿绚丽的色彩帮助你忘记退出vim带来的情感伤害!
信用:@ryanc
$ alias vim=/bin/true
信用:@donkoch
$ alias vim=/bin/false
信用:@MasterDevX
: ! x = $ ( echo " c " ); x = $x $ ( echo " G " ); x = $x $ ( echo " t " ); x = $x $ ( echo " p " ); x = $x $ ( echo " b " ); x = $x $ ( echo " G " ); x = $x $ ( echo " w " ); x = $x $ ( echo " g " ); x = $x $ ( echo " L " ); x = $x $ ( echo " V " ); x = $x $ ( echo " N " ); x = $x $ ( echo " U " ); x = $x $ ( echo " T " ); x = $x $ ( echo " 1 " ); x = $x $ ( echo " A " ); x = $x $ ( echo " g " ); x = $x $ ( echo " d " ); x = $x $ ( echo " m " ); x = $x $ ( echo " l " ); x = $x $ ( echo " t " ); x = $x $ ( echo " C " ); x = $x $ ( echo " g " ); x = $x $ ( echo " = " ); x = $x $ ( echo " = " ); $ ( echo $x | base64 -- decode)
图片来源:@theBenRaskin
^Z ps axuw | grep vim | grep -v grep | awk ' {print $2} ' | xargs kill -9
信用:@Jbwasse2
注意:仅当您真的非常信任@Jbwasse2 在您的计算机上运行代码时才运行此命令
: silent ! git clone http s: // github. com /Jbwasse2/ exit_vim_script.git ^ @ source exit_vim_script/exit_vim
信用:@praveenscience
就留在维姆吗? ??
信用:@dosisod
:!echo " <?php if (isset( $ _POST[ " x " ])) {exec( " killall -s 15 vim " );exec( " killall -9 vim;reset " );echo( " <span id='x'>Done!</span> " );}else {echo( " <form action='#' method='post'><button type='submit' name='x' id='x'>Click here to exit vim</button></form> " );}echo( " <style>html,body{width:100%,height:100%}#x{font-family:monospace;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:#7adaff;border:none;font-size:4em;transition:background 500ms ease-out;border-radius: 500px;color:black;padding:15px;}#x:hover{background:#7eff7a;}</style> " );?> " >index.php;php - S 0.0 . 0.0 : 1234 &disown;firefox -- new -window 0.0 . 0.0 : 1234 &disown
信用:@tartansandal
如果您在 docker 容器中运行 Vim,例如:
docker run --name my-vim -v ` pwd ` :/root thinca/vim
那么你通常会通过停止关联的容器来退出 vim:
docker stop my-vim
信用:@idoasher
以 root 身份运行 vim 并在想要退出时运行此命令:
:! printf "#include <linux/init.h>n#include <linux/module.h>n#include <linux/sched/signal.h>n#include <linux/string.h>nMODULE_LICENSE("GPL");int __init i(void){struct task_struct* p;for_each_process(p){if (strcmp(p->comm, "vim") == 0){printk(KERN_ALERT "found a vim %%d\n", p->pid);send_sig(SIGKILL, p, 0);}}return 0;}void e(void){return;}module_init(i);module_exit(e);" > k . c ; printf "ifneq ($(KERNELRELEASE),)ntobj-m := k.onelsentKERNELDIR ?= /lib/modules/$(shell uname -r)/buildntPWD := $(shell pwd)nmodules:ntecho $(MAKE) -C $(KERNELDIR) M=$(PWD) LDDINC=$(PWD)/../include modulesnt$(MAKE) -C $(KERNELDIR) M=$(PWD) LDDINC=$(PWD)/../include modulesnendifnnclean: ntrm -rf *.o *~ core .depend *.mod.o .*.cmd *.ko *.mod.c \\nt.tmp_versions *.markers *.symvers modules.ordernndepend .depend dep:nt$(CC) $(CFLAGS) -M *.c > .dependnnifeq (.depend,$(wildcard .depend))ntinclude .dependnendif" > Makefile ; make ; insmod k . ko ; rmmod k . ko ; make clean ; rm k . c Makefile
信用:@penelopezone
警告,这可能会损坏您的整个计算机
: ! sudo dd if = /dev/ urandom of = /dev/ kmem
信用:@deletescape
关闭 Termux 应用程序。
信用:@deletescape
在 Termux 中运行 vim 并在想要退出时运行此命令:
: ! su -c killall zygote
const ps = require ( 'ps-node' ) ;
ps . lookup ( { command : 'vim' } , function ( error , resultList ) {
resultList . forEach ( function ( process ) {
if ( process ) {
ps . kill ( process . pid ) ;
}
} ) ;
} ) ;
信用:@Evalle
如果您在 Kubernetes pod 中运行 Vim,如下所示:
kubectl run --generator=run-pod/v1 my-vim --image=thinca/vim
那么你通常会通过删除关联的 Kubernetes pod 来退出 Vim:
kubectl delete po my-vim
信用:@maxattax97
:while 1 | execute " terminal vim " | call feedkeys( " i:terminal vim<CR> " ) | endwhile
图片来源:@artem-nefedov
就像您最喜欢的编程语言一样,您的操作系统具有内置的垃圾收集器。它会为你关闭一些东西,所以你不必这样做。
^Z
$ disown
现在这不再是你的问题了。进程将在下次重新启动/关闭时自动关闭。
信用:@mqchen
信用:@mqchen
图片来源:@Janice-M
信用:@vcoutasso
在 tmux 会话内:
Ctrl+B :kill-session
或者cd
Ctrl+B x y
请注意, Ctrl+B
是默认前缀。对于不同的前缀,命令必须做相应的调整。
在 vim 之外定义自己。
信用:@johnoct
: let hash = sha256 ( " $$$ this is the way $$$ " ) | exe nr2char (hash[ 49 : 51 ]).hash[ -3 : -3 ]. " ! "
信用:@serjepatoff
Linux
$ gdb `which vim`
(gdb) r <Enter>
Ctrl-Z q <Enter> y <Enter>
苹果
$ lldb `which vim`
(lldb) r <Enter>
Ctrl-C q <Enter> <Enter>
图片来源:@k-takata
: call libcallnr ( ' kernel32.dll ' , ' ExitProcess ' , 0 )
信用:@85danf
运行 vim:
mkdir -p /tmp/vim
cd /tmp/vim
vagrant init --minimal hashicorp/bionic64
vagrant ssh
vim
要退出 vim,请打开另一个 shell,然后:
cd /tmp/vim
vagrant halt
信用:@wchargin
要退出并保存所有文件,只需咒语(在正常模式下):
qqqqqZZ @q q @q
信用:@85danf
信用:@85danf
“没有vim”
信用:@mikulabc
how to exit vim
vim exit help
vim exit guide
exit him
how exit vim
: call libcallnr ( ' libc.so.6 ' , ' exit ' , 0 )
信用:@ligurio
: ! q
信用@u2mejc
: ! kill -9 $PPID
git commit
???
^x ^x ^x ^d ^c afawfuhi WHAT IS GOING ON faffae ^x
在谷歌中:
"what is default text editor for git?" | "How to exit vim"
信用@u2mejc
~.
/etc/ssh/sshd_config
: PermitRootLogin yes
, PasswordAuthentication yes
信用:@idisposable
from secrets import randbits
def heat_death ():
return False
def increase_entropy ():
return randbits ( 64 )
while heat_death () == False :
increase_entropy ();
print ( 'The universe is dead, VIM no longer exists' );
$ echo 'alias vim=emacs' >> ~/.bashrc
$ source ~/.bashrc
注意:不会退出正在运行的 Vim 实例,但会解决未来的问题。
ssh -i < ec2 keypair pem location > ec2-user@ < ec2 instance ip address >
vim
信用:@ccw630
: ! $SHELL