0

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.

  • 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 – Ibrahim Muhammad Aug 20 '11 at 19:41
4

Try,

:map <Esc>s :w

Or perhaps,

:map <Esc>s :w<CR>

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

| improve this answer | |
  • It is the least one. :map <Esc>s :w<CR> Thank you Marty – Peter Feb 6 '13 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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