在 VS Code 中一次向上或向下移动多行光标
Move Cursor Up or Down Multiple Lines at once in VS Code
Note: I have searched in Google and other SO posts, but none of them have helped me.
我知道我们可以使用 Alt+Arrow 向上或向下移动。有没有办法一次移动,比方说 25 行?我不想按 Alt+↑ 25 次。
是否有插件或内置功能可以执行此操作?
我问的原因是由于 VS Code 中的相对行号功能,一次移动多行更容易。
我不想在 keybindings.json
中指定每个数字(如图 )。
您可以使用multi-command
就像在 Photoshop 中移动某些东西时,箭头移动 1 个像素,Shift+箭头移动 20 个像素。
箭头键没有未使用的修饰符组合,因此我们必须选择其他键。
向上或向下移动 10 行的新键绑定
{
"key": "alt+numpad8", // or any other key combo
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction"
]
},
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "alt+numpad2",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction"
]
},
"when": "editorTextFocus && !editorReadonly"
}
也许你需要加一点延迟
"args": {
"interval": 50,
"sequence": [
为了更轻松地在行块中导航光标,您可以设置一个键绑定以一次向上或向下跳转 10 行(在您的 keybindings.json 中):
{
"key": "ctrl+up", // whatever keybinding you want
"command": "cursorMove",
"args": {
"to": "up",
"by": "line",
"value": 10 // change this if you want
},
"when": "editorTextFocus"
},
{
"key": "ctrl+down", // whatever keybinding you want
"command": "cursorMove",
"args": {
"to": "down",
"by": "line",
"value": 10 // change
},
"when": "editorTextFocus"
}
正如评论中所指出的,这来自 所以赞成。
Note: I have searched in Google and other SO posts, but none of them have helped me.
我知道我们可以使用 Alt+Arrow 向上或向下移动。有没有办法一次移动,比方说 25 行?我不想按 Alt+↑ 25 次。
是否有插件或内置功能可以执行此操作?
我问的原因是由于 VS Code 中的相对行号功能,一次移动多行更容易。
我不想在 keybindings.json
中指定每个数字(如图
您可以使用multi-command
就像在 Photoshop 中移动某些东西时,箭头移动 1 个像素,Shift+箭头移动 20 个像素。
箭头键没有未使用的修饰符组合,因此我们必须选择其他键。
向上或向下移动 10 行的新键绑定
{
"key": "alt+numpad8", // or any other key combo
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction"
]
},
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "alt+numpad2",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction"
]
},
"when": "editorTextFocus && !editorReadonly"
}
也许你需要加一点延迟
"args": {
"interval": 50,
"sequence": [
为了更轻松地在行块中导航光标,您可以设置一个键绑定以一次向上或向下跳转 10 行(在您的 keybindings.json 中):
{
"key": "ctrl+up", // whatever keybinding you want
"command": "cursorMove",
"args": {
"to": "up",
"by": "line",
"value": 10 // change this if you want
},
"when": "editorTextFocus"
},
{
"key": "ctrl+down", // whatever keybinding you want
"command": "cursorMove",
"args": {
"to": "down",
"by": "line",
"value": 10 // change
},
"when": "editorTextFocus"
}
正如评论中所指出的,这来自