Quick Save in (Neo-)Vim
2024-11-03
If you do pretty much everything in (neo-)vim like me, you’ve probably already built your mustle memory to type :w
or :qa
blazing fast. However, if you’re multilingual like I am, you’re probably also frequently frustrated because you cannot as quickly jump between normal and insert modes when you’re on a different input source, say Chinese or Japanese – and you need to be on normal mode first to save, that’s the rule. So to save you some time here is my solution – if you use iTerm2 as well:
- Go to iTerm2 → Settings → Keys → Key Bindings
- Use
+
to add a new key binding, choose⌘-s
or whatever binding you want, choose action “Send Text” and type\e:\w\na
That’s it. Now you can press ⌘-s
to save your file without leaving insert mode.
P.S. A drawback is that you're kinda forced back into insert mode even if you were on normal mode already. That being said, why don't you just :w
if you're on normal?