我听说微软发布了一个叫做Visual Studio Code的新编辑器,看起来相当不错。我需要的一个关键功能是多行编辑,但似乎找不到有关它是否具备这个功能的任何信息。
框选
Windows和Linux:按住Shift + Alt + '鼠标左键'
macOS:按住Shift + option + '单击'
Esc退出选择。
MacOS:按住Shift + Alt/Option + Command + '箭头键'
按下 Ctrl+Alt+向下箭头 或者 Ctrl+Alt+向上箭头 可以在下方或上方插入光标。
在Visual Studio中,我用于多行选择(也称为盒子选择)的快捷方式是Shift + Alt + 上/下/左/右。
要在Visual Studio Code中创建这个功能,可以将这些按键绑定添加到keybindings.json文件中(菜单 文件 → 首选项 → 键盘快捷方式 )。
{ "key": "shift+alt+down", "command": "editor.action.insertCursorBelow",
"when": "editorTextFocus" },
{ "key": "shift+alt+up", "command": "editor.action.insertCursorAbove",
"when": "editorTextFocus" },
{ "key": "shift+alt+right", "command": "cursorRightSelect",
"when": "editorTextFocus" },
{ "key": "shift+alt+left", "command": "cursorLeftSelect",
"when": "editorTextFocus" }
shift+alt+down
三次,然后再按一次 shift+alt+up
,它不会撤消我上一次按下向下箭头键的操作,以便只选择两行,而是添加了第一行之上的一行,所以最终选择了四行。此外,您需要按 Esc
键才能退出框选模式。我希望 VS Code 能提供原生的键盘框选支持,但这个答案是次优解。 - deadlydog在 Visual Studio Code 中进行多选,按住 Alt 键并开始单击您想要编辑的任何位置。
Visual Studio Code 支持多行编辑。