GithubHelp home page GithubHelp logo

how-to-exit-vim's Introduction

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

The hardware way

Credit: @Jorengarenar

Pull the plug out

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.

Russian Roulette mode

When you want to spice things up a bit:

$ timeout $RANDOM vim

The reboot way

Credit: @tctovsli In vi:

:!sudo reboot

how-to-exit-vim's People

Contributors

aarongorka avatar eur0pa avatar hakluke avatar robotman321 avatar tctovsli avatar tomnomnom avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.