Recently someone recommended I save in vim using shift Z Z. This is working great for me! How can I create a shortcut so that shift S S maps to :w?

  • Like what can be shorter than one key command (:w)? Do you want something with zero keys? :) – David Ferenczy Rogožan Feb 26 '16 at 0:17
  • Possible duplicate of save in insert mode (VIM) – David Ferenczy Rogožan Feb 26 '16 at 0:18
  • @DawidFerenczy shift ZZ is feels faster than :x. Similarly, shift S S would feel faster that :w – kilojoules Feb 26 '16 at 0:19
  • OK, it's up to you. I was never thinking I would need anything else than :w. So just map any key you want to that command and you'll have single-key save. – David Ferenczy Rogožan Feb 26 '16 at 0:26
  • Cool. I'm changing my question to reflect with. – kilojoules Feb 26 '16 at 0:37

execute this line in last line mode, or put it in your .vimrc

:map <S-s><S-s> :w<CR> 
| improve this answer | |

Originally you were asking for that fastest way to save. I would say that it can be this alias:

inoremap <F2> <c-o>:w<cr>

It creates an alias for F2 key which executes the command :w. You can use whichever other key you want instead of F2 of course. And you can put it to your .vimrc.

| improve this answer | |
  • I'm on a mac - pressing the f2 key is an awkward combo of fn+f2 – kilojoules Feb 26 '16 at 4:27
  • So why would you use F2? Use whichever key you want. – David Ferenczy Rogožan Feb 26 '16 at 15:31
  • In my experience most key bindings are already taken – kilojoules Feb 26 '16 at 15:55
  • zz isn't taken... – jdk1.0 Feb 16 at 17:49
  • @jdk1.0 zz is taken to scroll the line you are currently on to the center of the screen – Yaroslav Yakovlev Jun 21 at 16: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.