I have added this line in .vimrc so that pressing ctrl–s saves the current file
:nmap <C-s> :w!<cr>
:imap <C-s> <esc>:w!<cr>
But this is not working. Any suggestions about what I am doing wrong?
keyboard shortcutsvimvimrc
I have added this line in .vimrc so that pressing ctrl–s saves the current file
:nmap <C-s> :w!<cr>
:imap <C-s> <esc>:w!<cr>
But this is not working. Any suggestions about what I am doing wrong?
Best Answer
See this wikia.com article for the exact thing you're tyring to do: http://vim.wikia.com/wiki/Map_Ctrl-S_to_save_current_or_new_files
In a nutshell you need to do the following.
1. Add this to
~/.vimrc
2. Disable terminal's interpretation of Ctrl+S