1

I'd like to overload both Ctrl+S and Cmd+S to save a file if I happen to be editing something in Vim.

After some head-scratching I think I've discovered that ^S in a terminal is perhaps being caught by the shell for sending a signal to the process, or perhaps Vim is doing something special to not listen to it. I have a perl script that puts the term in raw mode which can read my mappings just fine (the ^S sends hex 0x13), but nothing happens when I am in Vim Ctrl+V verbatim-mode and type it. In the bare zsh shell, verbatim-mode does show me that I am pressing ^S. This seems to refute the proposition that there is some terminal program flow-control bound to this key, as I am able to get zsh to see it.

How can I get vim to recognize my Ctrl+S?

2 Answers 2

2

^S is the ASCII XOFF character. Together with XON (^Q), they are the two control signals used for software flow control.

They are not intercepted by the shell, but by the terminal, which intercepts ^S to mean halt terminal output and ^Q to mean resume it.

You can configure your terminal (using stty -ixon -ixoff) to ignore them by turning off software flow control, but it may be futile: it's ill-advised to attempt to assign other functions to XON and XOFF because there might be something else in the user's session (a remote terminal, a modem, some other piece of RS-232 equipment) that interprets them.

1

stty -ixon (and stty -ixoff for good measure) did it for Terminal.app, iTerm2.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .