Undo functionality is absolutely horrendous, there should be an option to opt-out, and just remap the 'u' to native VS Code undo.
- Extension (VsCodeVim) version: 1.25.2
- VSCode version: 1.76.0
- OS: Ubuntu
This works for mac, maybe it helps.
"vim.normalModeKeyBindings": [
{
"before": ["u"],
"commands": ["undo"]
},
]
Part of the problem may be that you're not used to how u works in Vim. Inserting an entire paragraph is considered one change. The idea is, you're supposed to "dip" into insert mode, then return to normal mode. It doesn't undo words or sentences, it undoes changes. So if you never hit escape, it'll just undo everything. I'm not going to call it operator error, but it kind of seems like it's a simple lack of information. Hope this helps!
(Of course, if it's a problem with the undo command itself, that's another thing. If that's the case, I can't help you; I'm just a user.)
My problem with it is:
- Make a change in a line
- Make a change in another line (same file)
- Undo with
u - The cursor jumps to the1st file change and undoes it
I haven't figured out a consistent way to trigger or avoid this. Sometimes it does the opposite: and undo actually works, but the cursor doesn't jump to the line where the undo happened so I'm left clueless unless I always go manually check whether the change was made some 300 lines above the current one.
@tonyjara Does this remapping always work for you and is stable? I've tried it but it doesn't seem to work for me. And the debugging output of VsCodeVim doesn't print anything related to it 😞
@vittorius It worked for me. I've also been using neovim for some time now so maybe something's changed.
@tonyjara I've found the cause of the problem. I've just tried VSCode Profiles, and looks like "vim.normalmodekeybindings" must be defined in the default profile JSON file (I'm using a custom profile currently). Too used to ignoring VSCode hints when editing settings files because sometimes these hints are wrong... Thanks for your help!
This works for mac, maybe it helps.
"vim.normalModeKeyBindings": [ { "before": ["u"], "commands": ["undo"] }, ]
Thank you!
In the age of Cursor the default vim-style undo has become nearly unusable. Mapping to ctrl/cmd+z style undo is critical now (for me at least).
It helps to also add 'redo':
"vim.normalModeKeyBindings": [
{
"before": ["u"],
"commands": ["undo"]
},
{
"before": ["<C-r>"],
"commands": ["redo"]
},
]