Using VS Code, how can I move the current line I am on (or the current selection) up or down using Vim keybindings? When using the editor as normal, I can achieve this using 'alt + up/down'.
I am using the vscodevim extension.
If you put the cursor on a line of code and use the Alt+Up Arrow keys, the line of code you've selected moves up. If you use the Alt+Down Arrow keys, the line of code selected moves down.
On Windows Shift + Alt + F. On Mac Shift + Option + F. On Linux Ctrl + Shift + I.
To move left, press h . To move right, press l . To move down, press j . To move up, press k .
adding the following to the settings.json
. It uses J
and K
to move the line down/up in the normal mode.
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["J"],
"commands": ["editor.action.moveLinesDownAction"]
}, // moveLineDown
{
"before": ["K"],
"commands": ["editor.action.moveLinesUpAction"]
} // moveLineUp
],
In vim there is no direct mapping for that, but what you can do is:
dd
p
to past your deleted line.That should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With