6
votes

Im using iTerm2 + Tmux + Vim.

Here are my dotfiles: https://bitbucket.org/furion/dotfiles/src

The problem I'm having, is when Vim is opened within Tmux session, the C-s binding doesn't work.

When I run Vim just in regular iTerm2 session, C-s works fine. Since I use this keystroke a lot, its really frustrating.

Also, this issue is only present on OSX. On my Arch box, Tmux or without, everything works fine.

EDIT: I already have control flow disabled:

bind -r '\C-s'
stty -ixon
stty stop undef

This issue is only on OSX. Also, its only under Tmux on OSX. Without Tmux no issue. On Arch Linux With or w/o Tmux, no issue.

3
you had asked a similar question here stackoverflow.com/questions/17991007/… the solution there doesn't help? - Kent
No, that was a different problem, which has been solved. I got it to work on Arch that time. - if __name__ is None
I checked your .vimrc, you want to do :w when <c-s> was pressed? but that line was commented out. - Kent
No, I use it in Ctrl-P Plugin, to open files in split buffers. I have very strong muscle memory with :w, so I might as well remove C-s there. - if __name__ is None
Same problem happens to me and I haven't found a fix. It is intermittent almost random. Quitting vim and starting it again fixes it for a while. I think it mush be something with vim getting confused with something that tmux is doing. Maybe a mouse thing? I don't know. Crap... vim just crashed on me. I got to go... - Sukima

3 Answers

4
votes

It probably has to do with flow control: historically (and still today, in some terminals), Ctrl-S pauses the output, and Ctrl-Q resumes it.

iTerm2 ignores Ctrl-S, as it assumes that it has no use for flow control in the world where 300 and 2400 baud modems are not all that common.

I am not sure, but I think stty -ixon might help.

(I'm tentatively answering since it's been 5 hours, but I might be way off on the solution, even though I think the cause is correct).

1
votes

I figured out the fix, But I don't know the reason why this happens

I make a TMUX command to reload the config file also run stty -ixon.

This has to be done manually even though it is set in the .bashrc or .profile since the problem manifests itself after initialization.

Here is the relevant TMUX config line:

bind-key r run "tmux source-file ~/.tmux.conf; stty -ixon"
0
votes

I found this question when trying to fix the problem of Ctrl-S in bash in iTerm on macOS not activating forward-search-history (aka: i-search) in spite of having:

$ bind -p | grep 'forward-search-history'
"\C-s": forward-search-history

I found that it DID NOT solve the problem to put stty -ixon in .bashrc but putting in in .bash_profile does solve it. So, maybe that will help others that Google leads here.

$ grep stty ~/.bash_profile
stty -ixon