相关疑难解决方法(0)

如何使用 vscode 在新行中插入片段?

我正在尝试为 python 制作一个 vscode 片段。假设我有这样一行代码:

my_var = call_some_function()
Run Code Online (Sandbox Code Playgroud)

我想双击 my_var 来选择它,按下一个键,它会产生以下结果:

my_var = call_some_function()
LOGGER.debug("my_var: %s", my_var)
<cursor is here>
Run Code Online (Sandbox Code Playgroud)

它也应该适用于表达式,就像我在这一行中选择“x + y + z”并按下键:

call_function(x + y + z)
Run Code Online (Sandbox Code Playgroud)

它应该产生:

call_function(x + y + z)
LOGGER.debug("x + y + z: %s", x + y + z)
<cursor is here>
Run Code Online (Sandbox Code Playgroud)

显然使用调试器更好。但有时您不能使用调试器。

code-snippets visual-studio-code

5
推荐指数
1
解决办法
2026
查看次数

标签 统计

code-snippets ×1

visual-studio-code ×1