在使用Python的VS Code中,我们可以在“ Python交互式窗口”中运行“单元”(以#%%
开头的块)
我们可以在集成终端上做同样的事情吗?
我知道我们可以在Spyder中执行此操作,其中终端通常始终是IPython终端]
Matlab与终端的工作方式相同。
我们可以在VS Code中做到吗?
我已经打开了issue in GitHub,但似乎他们没有这样做的意图。
我正在为其他用户提供解决方法:
1。具有“选择依据”扩展名:
https://marketplace.visualstudio.com/items?itemName=rioj7.select-byhttps://github.com/rioj7/select-by
2。具有“宏”扩展名:
https://marketplace.visualstudio.com/items?itemName=ctf0.macroshttps://github.com/ctf0/macros
3。将波纹管放在settings.json
:
"selectby.regexes": {
"regex1": {
"flags": "i",
"backward": "#.*%%.*\r",
"forward": "#.*%%.*\r",
"backwardInclude": false,
"forwardInclude": false
},
},
"macros.list": {
"RunCellinTerminal": [
"cursorEnd",
"selectby.regex1",
"workbench.action.terminal.runSelectedText",
"cursorEnd",
]
}
4。执行宏“ RunCellinTerminal”
将光标放在所需的单元格内,当执行宏时,将选择该单元格的区域,并将文本发送到打开的活动终端。
这里是一个示例:(可以添加键绑定)