I often go around editing things in normal mode only to realise my change was not intended, as such, I undo and then press K/L/J/H to continue but meanwhile I am already in insert mode, so I have to get out of it first.
I would like to insert a rule on my .vimrc to put me back on the mode I was on just before any changes that I did.
IE: shift+s (delete line and start editing) -> undo : Back in normal mode Bonus: ciw -> asdahsdasdh -> undo: Back in normal mode
PS: I am actually using Undo with Command+Z, the default MacOSX undo combination.
OS X is capturing the Cmdz keyboard event and handling undo at the application level, so any mapping for
<D-z>
will be ignored. However, you can override this to do what you want.First, add a mapping to your .vimrc:
Restart MacVim to ensure the .vimrc has been reloaded.
To get this to work you also need to tell MacVim to not use Cmdz for the "Undo" menu item.
(These directions are based on Yosemite/El Capitan but are similar for older versions.)
(I chose ShiftCtrlOptCmdx.)
Now going back to MacVim, if you pull down the Edit menu, "Undo" should have the key combination you chose, and your Cmdz shortcut should work as you described.