Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been trying to get Vim to remap CTRL+S (or ^S) to :w by editing my .vimrc file, however it doesn't work.

This is my current ~/.vimrc configuration:

nmap <c-s> :w<CR>
imap <c-s> <Esc>:w<CR>
imap <c-s> <Esc><c-s>

I read that CTRL+S can run a command which freezes the terminal, however I don't seem to experience this.

If I do press CTRL+S, nothing happens. If I then do ESC and :q I'm informed that I haven't already saved changes.

:current tells me that user vimrc file: "$HOME/.vimrc".

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

In the whole <C-a> -> <C-z> range, <C-s> and <C-q> are the only two that can't be mapped in CLI Vim because they are intercepted before they reach the editor.

What they are meant to be used for, flow control, is mostly an artefact of the relatively long history of terminals and networked computing and not really relevant today.

The simplest way to get back the full alphabet for your Ctrl mappings is to add this line to your *rc:

stty -ixon
share|improve this answer
    
Thanks- I had that at the very end of my .bashrc moved it to the top and CTRL<S works. –  Nysepho Apr 28 '13 at 19:04
    
Though there may be applications that require terminal flow control (CTRL-S). Just something to be aware of in case of problems. –  suspectus Apr 28 '13 at 19:14
    
I haven't come across any before, hopefully I won't though. –  Nysepho Apr 28 '13 at 21:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.