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 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.

share|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
add comment

1 Answer

up vote 4 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.

share|improve this answer
    
Thanks, it works. –  whistler Aug 20 '11 at 19:36
    
It is the least one. :map <Esc>s :w<CR> Thank you Marty –  Peter I Feb 6 '13 at 8:38
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.