Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to map to save in vim in a standard terminal? I know how to set it in my vimrc but am not sure if it is possible to pass it from terminal to vim instead of attempting to save the terminal.

share|improve this question
Would MacVim be an option ? It uses cmd+s for saving. And you can start it from terminal with mvim. – iolsmit Apr 20 '12 at 10:36
I am using vim with tmux so macvim wouldn't work. – TCoville Apr 27 '12 at 1:48
up vote 1 down vote accepted

Yes you should be able to set up a key mapping in your .vimrc file so that when you press command - S it maps to :w Also here is something else to go on that you can modify as well Map Ctrl-S to save current or new files

  • First thing is to reassign the the Command - S functionality for the Application. Do this in the Keyboard > Keyboard Shortcuts System Preference Pane.

For example, you will want to add in a new Application Short cut for the Terminal app, then map to the Menu title "Export Text As..." to another keyboard command something that you don't use, e.g. control - s or etc. should be fine.

Something such as this noted below* you can add to you .vimrc:

:map <M-s> :w<kEnter>  "Works in normal mode, must press Esc first"
:imap <M-s> <Esc>:w<kEnter>i "Works in insert mode, saves and puts back in insert mode"

*This was verified working on the X11 terminal on OS X Lion.

share|improve this answer
Thanks, will keep an eye on that thread to see if there is a way to get cmd-s passed to the app. – TCoville Apr 27 '12 at 1:48

For people still coming across this, I've written up an inverse of MrDaniel's solution (that is, mapping any MacVim / system-wide ⌘-sequence to command-line vim), and posted it to his other question. It's more complex than his solution, but then allows you to (with some effort) remap any ⌘-sequence into any command-line program.

It works well for me, and I hope it can help you too. <3

share|improve this answer

Your Answer


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.