Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Cannot bind the moving keymap :m

Open Abel2333 opened this issue 1 year ago • 2 comments

Describe the bug I try to bind <leader> j to :m .+1 like this:

"vim.normalModeKeyBindings": [
{
            "before": [
                "leader",
                "j"
            ],
            "commands": [
                ":m .+1 ",
            ],
            "after": [
                "=="
            ],
            "silent": true
        }
]

To Reproduce But it does not work. I pressed <leader> j, but nothing happened until I pressed ':'. In this case, the current line will move to the next line and I enter the operator pending mode. Why do I have to press the additional ':' to make commands useful?

Expected behavior What I want to happen is for the current line to move to the next line immediately.

Screenshots Here is the log: image

2024-01-22 01:27:31.908 [debug] Handling key: <space>
2024-01-22 01:27:32.553 [debug] Handling key: k
2024-01-22 01:27:32.557 [debug] Adding Transformation {"type":"deleteRange","range":[{"line":88,"character":0},{"line":89,"character":0}],"manuallySetCursorPositions":true}
2024-01-22 01:27:32.557 [debug] Adding Transformation {"type":"insertText","position":{"line":86,"character":0},"text":"\n    cutoff_frequency = fc * 2 * offset","diff":{"type":0,"line":87,"character":4}}
2024-01-22 01:27:32.557 [debug] Status bar: :move .-2 
2024-01-22 01:27:35.969 [debug] Handling key: :
2024-01-22 01:27:35.997 [debug] 2 change(s) to \home\abel\Study\Digital-Communication\Digital_Modulation\QPSK.py because undefined

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 1.27.2
  • VSCode version: 1.85.2
  • OS: Windows_NT

Abel2333 avatar Jan 22 '24 01:01 Abel2333

I also encountered similar problems

ycpss91255 avatar Feb 06 '24 18:02 ycpss91255

The "after" may not necessarily be executed after "commands"

For your requirement, you can use the following binding to implement it

    {
      "before": ["leader", "l"],
      "commands": [
        ":m .+1",
        {
          "command": "vim.remap",
          "args": {
            "after": ["<Esc>", "=", "="]
          }
        }
      ],
      "silent": true
    },

HenryTSZ avatar Jun 25 '24 08:06 HenryTSZ

The "after" may not necessarily be executed after "commands"

For your requirement, you can use the following binding to implement it

    {
      "before": ["leader", "l"],
      "commands": [
        ":m .+1",
        {
          "command": "vim.remap",
          "args": {
            "after": ["<Esc>", "=", "="]
          }
        }
      ],
      "silent": true
    },

It works, thank you!

Abel2333 avatar Jul 14 '24 16:07 Abel2333