Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Undo functionality is absolutely horrendous, there should be an option to opt-out, and just remap the 'u' to native VS Code undo.

Open caldwell-63 opened this issue 3 years ago • 7 comments

  • Extension (VsCodeVim) version: 1.25.2
  • VSCode version: 1.76.0
  • OS: Ubuntu

caldwell-63 avatar Mar 07 '23 04:03 caldwell-63

This works for mac, maybe it helps.

"vim.normalModeKeyBindings": [
   {
      "before": ["u"],
      "commands": ["undo"]
    },
]

tonyjara avatar Mar 09 '23 01:03 tonyjara

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.)

darkwater4213 avatar Mar 22 '23 03:03 darkwater4213

My problem with it is:

  1. Make a change in a line
  2. Make a change in another line (same file)
  3. Undo with u
  4. 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.

andradei avatar Apr 26 '23 20:04 andradei

@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 avatar Jun 23 '23 09:06 vittorius

@vittorius It worked for me. I've also been using neovim for some time now so maybe something's changed.

tonyjara avatar Jun 23 '23 09:06 tonyjara

@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!

vittorius avatar Jun 23 '23 09:06 vittorius

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"]
    },
]

matbess avatar Sep 02 '25 21:09 matbess