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

308

u/k-selectride May 23 '17

I wonder how many people need help after hitting Ctrl-s

110

u/SilverCodeZA May 23 '17

Hooray for Konsole. It pops up a warning at the top of the screen telling you output has been suspended and to press Ctrl-Q to resume. I'm sure I have been caught by this in non Konsole based terminals though.

11

u/schwerpunk May 23 '17 edited May 25 '17

On konsole 17.04.1, and just tested. No popup. Using i3 as my window manager.

EDIT: Tested on two more (floating) wms - no notification. Am I missing a config option?

5

u/SilverCodeZA May 24 '17

Just checked now, and it works when I'm local, but if I ssh to another machine it doesn't. I guess it is the remote terminal pausing output so Konsole can't pick it up.

44

u/[deleted] May 23 '17

Oh my god, this is probably the most irritating thing about working in the terminal for me. I enable ctrl-S so I can do a forwards i-search in bash, but I occasionally​ hit it in vim when aiming for ctrl-D, and it totally baffles me every time.

40

u/Works_of_memercy May 23 '17 edited May 23 '17

Put

"\e[A": history-search-backward
"\e[B": history-search-forward

in your .inputrc and join the path of glory. Then up/down arrows cycle through history commands starting with the current command prefix (which by the way is strictly better than how ctrl-R works).

Then you can disable ctrl-S (stty ixany ixoff -ixon in .bashrc, probably guarded by if [[ "$-" == *i* ]]; then to only do that in interactive mode) and use ctrl-Z, whatever, fg if you want to pause some program and look at its recent output.

11

u/evaned May 23 '17

Then up/down arrows cycle through history commands starting with the current command prefix (which by the way is strictly better than how ctrl-R works)

I routinely use ctrl-r to search for substrings that don't begin the line. How is your thing strictly better?

7

u/Works_of_memercy May 23 '17

Oh, OK, it's strictly better when you want to complete the beginning of the command from history, and you can still use ctrl-R otherwise, but yeah, you are correct.

3

u/evaned May 23 '17

Yay technicality. :-)

That being said, I'm definitely going to have to start trying that out and see what I think, so thanks for the suggestion!

3

u/Works_of_memercy May 23 '17

Keep in mind that the usefulness of this thing is proven by the way you curse and flail your arms in frustration when trying to do stuff from someone else's terminal or sshing to some other server. And it's really useful and therefore really annoying when absent in such situations.

I wonder if there's some way to put yourself into your familiar shell with all sorts of .*rc stuff with minimal amount of keystrokes to initiate it.

→ More replies (1)

5

u/Godd2 May 23 '17

Also tab and shift-tab for autocompletion

# Autocompletion
#
# press tab to cycle autocomplete
"\t":menu-complete
# shift-tab to cycle backwards
"\e[Z":menu-complete-backward

menu-complete-backward was added in bash v4.0.0

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

42

u/[deleted] May 23 '17

OH MY GOD, THAT'S WHY I ALWAYS THINK MY CONSOLE IS STUCK.

Thank you SO MUCH.

4

u/thewatcheruatu May 23 '17

Ha! This one gets me every time! I do it frequently enough that it's super obnoxious, but rarely enough that I always have to look up the command to get back to normal.

2

u/skeletal88 May 24 '17

That's one of the most irritating things that happened. I used to do stuff remotely with putty and I hit ctr-S often out of habit (saving current work) and I only figured out why tf the shell froze years after. Very annoying.

1

u/Bratmon May 24 '17

Me! It's me! I'm the one!

Emacs muscle memory put me there and Stack Overflow took me out.

1

u/ivan0x32 May 24 '17

Okay, how do I exit it now?

3

u/POGtastic May 24 '17

Ctrl-Q.

Ctrl-S suspends input. Ctrl-Q resumes.

1

u/noratat May 24 '17

Oh wow, I'd completely forgotten about that. Most systems these days it's no longer an issue, and I have it taken care of in my config files.

1

u/DuneBug May 24 '17

my favorite part of vi as a noob. especially coming from Windows where you use ctrl+s all the time.

1

u/michaelpaoli May 24 '17

That's Unix/Linux, not vim specific. Actually even more generally than that, as that's ASCII XOFF standard default software flow control stop character.

And of course Ctrl-U to resume (XON start).

2

u/k-selectride May 24 '17

It is, but people get bamboozled by it all the time while in vim.

→ More replies (1)

1

u/jvnane May 24 '17

What does that do? I have ctrl+s set to my tmux hotkey, or whatever it's called.

→ More replies (1)

1

u/TabCompletion May 24 '17

I always thought this problem was a sick joke Unix guys are playing on people who are used to windows ctrl-s.