To ensure that this workaround runs even when Vim is started by a separate tool (such as git), I have this in my
" Allow us to use Ctrl-s and Ctrl-q as keybinds
silent !stty -ixon
" Restore default behaviour when leaving Vim.
autocmd VimLeave * silent !stty ixon
This has been working for me on Linux, GVim, Mac OS X and MacVim.
On Windows, or any other OS lacking the
stty command, the above will likely throw up errors every time Vim starts! (
silent! might mute that.)
If your shell already had this TTY setting disabled, of course the
VimLeave autocommand will turn it back on again! Detecting and restoring the current settings is an advantage with @aPyDeveloper's approach.
A combination of this and @aPyDeveloper's solution, which handles compatibility concerns under OS X and Windows, would be great to post up here and/or on the Wiki!
To avoid choosing between
stty -g and
stty --save, you could try the following test for just the
call system("stty -a | grep '\( \|^\)ixon\>' >/dev/null")
let g:ix_at_startup = (v:shell_error == 0)