Vim: undo in vim extension can't be redo-ed by the redo command of vscode

Created on 27 Apr 2018  路  9Comments  路  Source: VSCodeVim/Vim

Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT

What happened:
The action of the u command cannot be redo-ed by 鈬р寴Z(which is the redo key of vscode, which did nothing).

What did you expect to happen:
The affect of the u command should no longer take place.

How to reproduce it (as minimally and precisely as possible):

  1. Type any text with vim extension enabled
    Result:
    test me

  2. Use the u command
    Result:
    (blank)

  3. Try redo with vscode
    Result:
    (blank)
    Which I expect to be:
    test me

Environment:

  • Extension (VsCodeVim) version: 0.11.5
  • VSCode version: 1.22.2
  • OS version: Darwin x64 17.5.0
statuby-design

Most helpful comment

I rewirte the action on "u" and <c-r>, now it work very well, it use the vscode undo and redo command.
setting.json

    "vim.useCtrlKeys": true,
    "vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": ["u"],
            "commands": ["undo"]
        },
        {
            "before": ["<C-r>"],
            "commands": ["redo"]
        }
    ],

and I expect the extension do it default.

All 9 comments

@myzhang1029 , I believe this is right behavior, because VSCodeVim uses its own stack for undo/redo actions. Any undo action made with VIM plugin is actually common edit operation, from VSCode point of view, so there is basically, nothing to redo at that moment

@Nodman Thanks a lot.

so.... what's the solution? I'm constantly accidentally undoing things and losing them forever.

ctrl+r wasn't working for me but I was able to bind redo to a different keybinding:

    {
        "key": "shift+u",
        "command": "extension.vim_ctrl+r",
        "when": "textInputFocus && vim.mode != 'Insert'"
    },

I rewirte the action on "u" and <c-r>, now it work very well, it use the vscode undo and redo command.
setting.json

    "vim.useCtrlKeys": true,
    "vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": ["u"],
            "commands": ["undo"]
        },
        {
            "before": ["<C-r>"],
            "commands": ["redo"]
        }
    ],

and I expect the extension do it default.

You are awesome @coppyC. thanks!

ctrl+r wasn't working for me but I was able to bind redo to a different keybinding:

    {
        "key": "shift+u",
        "command": "extension.vim_ctrl+r",
        "when": "textInputFocus && vim.mode != 'Insert'"
    },

It works for me. Thank you :thumbsup:

Now I can use u to undo and U to redo in VScode vim.

image

Thanks @coppyC and I totally agree with you that this should be the default. This has been an infuriating issue where I've assumed I'd hit some disastrous combination of keys and lost work multiple times. I've even switched back to Atom a couple times due to this issue.

The only thing that worked for me:

"vim.normalModeKeyBindings": [
  {
    "before":["U"],
    "commands":["extension.vim_ctrl+r"]
  }
]
Was this page helpful?
0 / 5 - 0 ratings

Related issues

WangRongda picture WangRongda  路  3Comments

gerardmrk picture gerardmrk  路  3Comments

orn688 picture orn688  路  3Comments

liamdawson picture liamdawson  路  3Comments

elithrar picture elithrar  路  3Comments