VS Code 在 运行 上移动到下一行 ctrl + enter
VS Code move to next line on run ctrl + enter
我是 VS Code 的新手,我使用 Ctrl + 运行 代码进入 python 交互式 window输入。我希望光标自动移动到下一行,这样我就可以逐行查看代码。
这可以做到吗?
如 this blog post 中所述,以下是如何使用 Ctrl + enter[= 进行 VS Code 运行 代码选择16=] 并移至下一行:
###############################
# 1. Install extension "macros" in Visual Code
#
# Hit View on top menu
# Search for extension named "macros" (by geddski)
# Install "macros" extension
#
###############################
###############################
# 2. Add code below to keybindings.json
#
# Hit <Crtl> + <Shift> + <P>
# Enter in search bar: JSON
# Select Open keyboard shortcuts
#
###############################
{
"key": "ctrl+enter",
"command": "macros.pythonExecSelectionAndCursorDown",
"when": "editorTextFocus && editorLangId == 'python'"
}
###############################
# 3. Add code below to settings.json
#
# Hit <Crtl> + <Shift> + <P>
# Enter in search bar: JSON
# Select Open settings
#
###############################
"macros": { // Note: this requires macros extension by publisher:"geddski"
"pythonExecSelectionAndCursorDown": [
"python.execSelectionInTerminal",
"cursorDown"
]
}
上面 P.Marres 的回答显示 this blog post 的代码很棒! linux.
中的 windows 子系统需要这个
以下是 Visual Studio 中 Linux 的 Windows 子系统的处理方法代码:
###############################
# 1. Install extension "macros" in Visual Code
#
# Hit View on top menu
# Search for extension named "macros" (by geddski)
# Install "macros" extension
#
###############################
###############################
# 2. Add code below to keybindings.json
#
# Hit <Crtl> + <Shift> + <P>
# Enter in search bar: JSON
# Select Open keyboard shortcuts
#
###############################
{
"key": "ctrl+enter",
"command": "macros.ExecSelectionAndCursorDown",
}
###############################
# 3. Add code below to settings.json
#
# Hit <Crtl> + <Shift> + <P>
# Enter in search bar: JSON
# Select Open settings
#
###############################
"macros": { // Note: this requires macros extension by publisher:"geddski"
"ExecSelectionAndCursorDown": [
"workbench.action.terminal.runSelectedText",
"cursorDown"
]
}
P.Marres 建议的框架在“运行 及以下”部分对我有用,但它会向终端发送命令。以下设置帮助我在交互式 window.
中 运行 一个 .py
文件“上下”
先决条件:
- 发布者的宏扩展:“geddski”
- Jupyter 扩展(默认安装 Python 扩展,替换旧的
python.datascience
)
在keybindings.json中,包括:
[
{
"key": "ctrl+enter",
"command": "macros.pythonExecSelectionAndCursorDown",
"when": "editorTextFocus && editorLangId == 'python'"
},
{
"key": "ctrl+enter",
"command": "macros.jupyterExeSelThenCursorDown",
"when": "editorTextFocus && isWorkspaceTrusted && jupyter.ownsSelection && !findInputFocussed && !notebookEditorFocused && !replaceInputFocussed && editorLangId == 'python'"
},
{
"key": "ctrl+enter",
"command": "macros.pythonExecSelectionAndCursorDown",
"when": "editorTextFocus && !findInputFocussed && !jupyter.ownsSelection && !notebookEditorFocused && !replaceInputFocussed && editorLangId == 'python'"
},
{
"key": "ctrl+enter",
"command": "macros.jupyterRunCellThenCursorDown",
"when": "editorTextFocus && isWorkspaceTrusted && jupyter.hascodecells && !editorHasSelection && !notebookEditorFocused"
},
{
"key": "ctrl+enter",
"command": "macros.interactiveExe",
"when": "resourceScheme == 'vscode-interactive'"
}
]
在settings.json中包括:
"macros": {
"pythonExecSelectionAndCursorDown": [
"python.execSelectionInTerminal",
"cursorDown"
],
"jupyterExeSelThenCursorDown":[
"jupyter.execSelectionInteractive",
"cursorDown"
],
"jupyterRunCellThenCursorDown":[
"jupyter.runcurrentcelladvance",
"cursorDown"
],
"interactiveExe":[
"interactive.execute",
"cursorDown"
]
}
我是 VS Code 的新手,我使用 Ctrl + 运行 代码进入 python 交互式 window输入。我希望光标自动移动到下一行,这样我就可以逐行查看代码。
这可以做到吗?
如 this blog post 中所述,以下是如何使用 Ctrl + enter[= 进行 VS Code 运行 代码选择16=] 并移至下一行:
###############################
# 1. Install extension "macros" in Visual Code
#
# Hit View on top menu
# Search for extension named "macros" (by geddski)
# Install "macros" extension
#
###############################
###############################
# 2. Add code below to keybindings.json
#
# Hit <Crtl> + <Shift> + <P>
# Enter in search bar: JSON
# Select Open keyboard shortcuts
#
###############################
{
"key": "ctrl+enter",
"command": "macros.pythonExecSelectionAndCursorDown",
"when": "editorTextFocus && editorLangId == 'python'"
}
###############################
# 3. Add code below to settings.json
#
# Hit <Crtl> + <Shift> + <P>
# Enter in search bar: JSON
# Select Open settings
#
###############################
"macros": { // Note: this requires macros extension by publisher:"geddski"
"pythonExecSelectionAndCursorDown": [
"python.execSelectionInTerminal",
"cursorDown"
]
}
上面 P.Marres 的回答显示 this blog post 的代码很棒! linux.
中的 windows 子系统需要这个以下是 Visual Studio 中 Linux 的 Windows 子系统的处理方法代码:
###############################
# 1. Install extension "macros" in Visual Code
#
# Hit View on top menu
# Search for extension named "macros" (by geddski)
# Install "macros" extension
#
###############################
###############################
# 2. Add code below to keybindings.json
#
# Hit <Crtl> + <Shift> + <P>
# Enter in search bar: JSON
# Select Open keyboard shortcuts
#
###############################
{
"key": "ctrl+enter",
"command": "macros.ExecSelectionAndCursorDown",
}
###############################
# 3. Add code below to settings.json
#
# Hit <Crtl> + <Shift> + <P>
# Enter in search bar: JSON
# Select Open settings
#
###############################
"macros": { // Note: this requires macros extension by publisher:"geddski"
"ExecSelectionAndCursorDown": [
"workbench.action.terminal.runSelectedText",
"cursorDown"
]
}
P.Marres 建议的框架在“运行 及以下”部分对我有用,但它会向终端发送命令。以下设置帮助我在交互式 window.
中 运行 一个.py
文件“上下”
先决条件:
- 发布者的宏扩展:“geddski”
- Jupyter 扩展(默认安装 Python 扩展,替换旧的
python.datascience
)
在keybindings.json中,包括:
[
{
"key": "ctrl+enter",
"command": "macros.pythonExecSelectionAndCursorDown",
"when": "editorTextFocus && editorLangId == 'python'"
},
{
"key": "ctrl+enter",
"command": "macros.jupyterExeSelThenCursorDown",
"when": "editorTextFocus && isWorkspaceTrusted && jupyter.ownsSelection && !findInputFocussed && !notebookEditorFocused && !replaceInputFocussed && editorLangId == 'python'"
},
{
"key": "ctrl+enter",
"command": "macros.pythonExecSelectionAndCursorDown",
"when": "editorTextFocus && !findInputFocussed && !jupyter.ownsSelection && !notebookEditorFocused && !replaceInputFocussed && editorLangId == 'python'"
},
{
"key": "ctrl+enter",
"command": "macros.jupyterRunCellThenCursorDown",
"when": "editorTextFocus && isWorkspaceTrusted && jupyter.hascodecells && !editorHasSelection && !notebookEditorFocused"
},
{
"key": "ctrl+enter",
"command": "macros.interactiveExe",
"when": "resourceScheme == 'vscode-interactive'"
}
]
在settings.json中包括:
"macros": {
"pythonExecSelectionAndCursorDown": [
"python.execSelectionInTerminal",
"cursorDown"
],
"jupyterExeSelThenCursorDown":[
"jupyter.execSelectionInteractive",
"cursorDown"
],
"jupyterRunCellThenCursorDown":[
"jupyter.runcurrentcelladvance",
"cursorDown"
],
"interactiveExe":[
"interactive.execute",
"cursorDown"
]
}