英文:
How to skip empty lines but not blocks in vs code?
问题
我想要一个键绑定命令,将光标移动到下一行非空行。例如:
msg = "Hello World"
print(msg)
将光标移动到这些行之间,跳过它们之间的空行。
英文:
I would like a keybinding command to move cursor to next non empty line.
For example:
msg = "Hello World"
print(msg)
Move the cursor between these lines skipping the empty lines in between.
答案1
得分: 1
你需要一个扩展来实现这个功能。我假设其他“跳转”扩展也可以做到,但是这里有一个我写的扩展,Jump and select,你可以在你的keybindings.json
中设置一些按键绑定,如下所示:
{
"key": "alt+down", // 你想要的任何按键绑定
"command": "jump-and-select.jumpForward",
"args": {
// 转到下一行/上一行不为空的行
"text": "^.",
}
},
{
"key": "alt+up",
"command": "jump-and-select.jumpBackward",
"args": {
"text": "^.",
// "text": "#\\d+\n" // 在必要时进行双重转义
}
}
英文:
You will need an extension for that. I assume that other "jumping" extensions can do it but here is an extension I wrote, Jump and select, for which you can set up a couple of keybindings (in your keybindings.json
) like so:
{
"key": "alt+down", // whatever keybindings you want
"command": "jump-and-select.jumpForward",
"args": {
// go to next/previous line that isn't empty
"text": "^.", // <== can use strings or regexp's here
}
},
{
"key": "alt+up",
"command": "jump-and-select.jumpBackward",
"args": {
"text": "^.",
// "text": "#\\d+\n" // double-escaped where necessary
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论