I want a shortcut to save the current file in Vim. I want to map escape+s to :w. I tried

:map <esc-s> :w 

but it doesnt work.

link|improve this question
In case you weren't aware, this will obscure a vim function. s in normal mode deletes the character under the cursor and enters insert mode. – Marty Aug 20 '11 at 3:56
You are mixing two native vim commands to do the work of another native vim command. :w is better than <Esc>s because it doesn't force you to reach for the <Esc> key. – romainl Aug 20 '11 at 7:04
Marty: Well i didnt know you could do that with s. I have mapped <C-s> to :w now. Had to tweak the terminal for that though. romainl: I have escape mapped to my caps lock so its not a problem – whistler Aug 20 '11 at 19:41
feedback

1 Answer

up vote 2 down vote accepted

Try,

:map <Esc>s :w

Or perhaps,

:map <Esc>s :w<CR>

<CR>, <Enter>, and <Return> are the keycodes for the return/enter key.

link|improve this answer
Thanks, it works. – whistler Aug 20 '11 at 19:36
feedback

Your Answer

 
or
required, but never shown

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