r/programming • • May 23 '17

Stack Overflow: Helping One Million Developers Exit Vim

https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/
9.2k Upvotes

1.1k comments sorted by

View all comments

554

u/Yehosua May 23 '17

Exiting Vim is easy.

Esc, Alt-X, Ctrl-Q, Ctrl-C Ctrl-C Ctrl-C, "ARGH", Alt-Tab to another window, killall -9 vim

328

u/DownvoteALot May 23 '17

"Alt-Tab" damn noobs not on a headless server.

182

u/elpfen May 23 '17

...you don't have alt-tab mapped to next buffer in tmux?

69

u/-gh0stRush- May 23 '17

screen master race

22

u/schwerpunk May 23 '17 edited Mar 02 '24

I like to travel.

→ More replies (1)

3

u/[deleted] May 24 '17

I recently switched to tmux from screen and rather like it. Maybe give it a shot if you haven't :)

→ More replies (3)
→ More replies (2)

12

u/[deleted] May 23 '17 edited May 23 '17

I keep meaning to try tmux.

One day. Muscle memory is a heckuva thing.

EDIT: "brew install tmux" locally. Added it to the list of packages my dev centos VMs get from Vagrant.

Me: https://media.giphy.com/media/rUS4Wfh2t2qdO/giphy.gif

7

u/TRiG_Ireland May 23 '17

Muscle memory is my problem with vim and git. Git always drops me into nano on my computer, but into vim on the server. I do remember how to get out of vim again, but I always hit the wrong button first.

→ More replies (4)
→ More replies (2)
→ More replies (2)

17

u/Cr3X1eUZ May 23 '17

Ctrl-Z to suspend it and kill from the shell?

6

u/aim2free May 23 '17

Doesn't work for me, I tried both

kill %1 and kill 1 "bash: kill: (1) - Operation not permitted", but it's still there. Aha, if I did

kill -9 %1    

then it worked.

3

u/towo May 24 '17

vim is suspended and can't react to the SIGTERM you sent with kill %1. You'd need to send a kill -CONT %1 after the SIGTERM so that it can be processed.

SIGKILL isn't parsed by the program itself, so it works regardless.

12

u/skztr May 23 '17

Yeah, clearly it should be ctrl+a n, ctrl+a c, killall vim, ctrl+a p, ctrl+a n, killall -9 vim, ctrl+a p, ctrl+a n, ps e | grep vim, ctrl+a p, ctrl+a :kill, ctrl+a n, man screen, man vim, man ps, restart, sudo restart, man sudo, visudo- AH FUCK

→ More replies (2)

22

u/Xynect May 23 '17

Why not just restart the PC like a normal human being?

20

u/fuzz3289 May 23 '17
 %s/vim/emacs/g

FTFY

31

u/knome May 23 '17

C-c C-c is undefined

→ More replies (1)

80

u/crixusin May 23 '17

You would think people realize that its probably badly designed if people are having trouble exiting your editor...

186

u/jl2352 May 23 '17 edited May 23 '17

It was designed in a time where there weren't common idioms for this type of thing. Today if you open a piece of software you expect ctrl or cmd c/x/v/a, to do the appropriate action. I don't even have to describe what they are. You know what ctrl+v does without me saying. Even many mobile operating systems support these (when they don't even have a ctrl key).

Vim predates stuff like that. You had to just invent it as you go.

Plus it's design also dates back to teletypes where some of this stuff made sense.

110

u/onmach May 23 '17

If you go ctrl+c, it actually tells you to Type :quit<Enter> to exit Vim.

50

u/evaned May 23 '17

If you're in insert mode, you have to do it twice; the first exits insert mode.

47

u/jrhoffa May 23 '17

Suicide is painless

8

u/[deleted] May 23 '17

it brings on many changes

→ More replies (1)
→ More replies (1)
→ More replies (19)
→ More replies (90)

61

u/mer_mer May 23 '17 edited May 23 '17

It makes sense in the context of vim, so I wouldn't recommend changing it. There's no reason to use vim unless you're willing to spend time learning how it works.

Edit: Meaning that there are a lot of easy text editors to use so there's no reason to morph vim into one of them. Vim is a power tool aimed directly at professionals who want to invest time into being more productive.

45

u/[deleted] May 23 '17 edited May 23 '17

You're being downvoted, but seriously! The way you exit vim is an artifact of the entire point of what vim is, i.e. modal editing. It's a powerful tool that is structured like that for a reason, and it objectively works well. Spending the couple of minutes it takes to internalize what an editing mode is seems like a perfectly reasonable prerequisite for using the software.

→ More replies (5)
→ More replies (4)
→ More replies (103)
→ More replies (8)