Vim
Vim copied to clipboard
Cannot bind the moving keymap :m
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:
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
I also encountered similar problems
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
},
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!