我需要一种快速的方法来使光标跳到自动换行 qoutes 或其他语法元素之外。我不想每次都必须向下按箭头键,并且绝对不想去我的鼠标。
有没有一种快速简便的方法可以为我的工作流程解决这个问题?
我需要一种快速的方法来使光标跳到自动换行 qoutes 或其他语法元素之外。我不想每次都必须向下按箭头键,并且绝对不想去我的鼠标。
有没有一种快速简便的方法可以为我的工作流程解决这个问题?
您可以使用快捷方式(shift+space或任何您喜欢的方式)来移动光标。
在你的Key Bindings - User
:
{ "keys": ["shift+space"], "command": "move", "args": {"by": "characters", "forward": true} }
最好的解决方案是在 Sublime Text 上录制宏,然后将其分配给键盘快捷键。按着这些次序:
通过在您的首选项 > 键绑定 - 用户文件中的方括号之间添加此快捷方式来创建快捷方式:
{
"keys": ["super+;"], "command": "run_macro_file", "args": {"file": "Packages/User/EndOfLine.sublime-macro"}
}
快乐编码!
进行键绑定的更完整方法是:
{ "keys": ["shift+space"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)\"\\]]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
假设您想要 shift+space作为快捷方式。或者您也可以将其更改 tab为
如在http://www.sublimetext.com/forum/viewtopic.php?f=3&t=5174#p23086
继 Riccardo Marotti 的帖子之后;
如果您想绕过下一行的括号,可以在 args 部分将“characters”替换为“lines”。
{ "keys": ["shift+space"], "command": "move", "args": {"by": "lines", "forward": true} }
在戴尔 XPS 上,Ctrl Enter 对我有用
我只是在名为 run_multiple_commands.py 的插件的帮助下部分实现了这个功能(见下文)
(仅在 ST3 上测试过,但该插件早于 ST3 的第一个版本,应该也可以在 ST2 上运行)。
快捷方式配置如下:
{
"keys": ["shift+space"],
"command": "run_multiple_commands",
"args": {
"commands": [
{"command": "move", "args": {"by": "characters", "forward": true} }
]
},
"context":
[
{ "key": "preceding_text", "operator": "regex_contains", "operand": "[)\\]}'\"]$", "match_all": true},
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
{
"keys": ["shift+space"],
"command": "run_multiple_commands",
"args": {
"commands": [
{"command": "move", "args": {"by": "characters", "forward": true} },
]
},
"context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)\\]}'\"]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
{
"keys": ["shift+space"],
"command": "run_multiple_commands",
"args": {
"commands": [
{"command": "move_to", "args": {"to": "brackets"} },
]
},
"context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[(\\[{]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
{
"keys": ["shift+space"],
"command": "run_multiple_commands",
"args": {
"commands": [
{"command": "move_to", "args": {"to": "brackets"} },
{"command": "move", "args": {"by": "characters", "forward": true} },
]
},
"context":
[
{ "key": "following_text", "operator": "not_regex_contains", "operand": "^[)\\]}'\"]", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "[)\\]}'\"]$", "match_all": true},
{ "key": "following_text", "operator": "not_regex_contains", "operand": "^[(\\[{]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
shift+space
四个条件的一个快捷方式 ( ):
光标就在引号或右括号/括号之后:
向前移动一个字符
光标就在引号或右括号/括号之前:
向前移动一个字符
光标就在打开括号/括号之前:
移动到右括号/括号
!1
&& !2
&& !3
:
移动到右括号/括号
再向前移动一个角色
run_multiple_commands.py
要在你的ST中使用这个配置,首先要在你的目录下添加一个名为的文件.../Package/User/
,其内容是本文第二段代码
该解决方案适合日常使用,但并不完美,因为:
Ctrl + M 是我在 Windows 机器上的默认设置。去做就对了
也许home和end键就在您的手指附近。
我使用ctrl+f将光标向前移动一格。此外,在 mac 上,我caps lock与ctrl. caps lock+f更容易到达。它对我来说效果很好。
我发现了另一种方式,它位于崇高的键绑定本身。基本上,我只是修改了自动关闭括号的键绑定,也就是说,我"contents": "($0)"
用"contents": "($1)$0"
. 然后只需点击Tab
即可摆脱括号。所以我在我的键绑定中添加了以下内容:
{ "keys": ["("], "command": "insert_snippet", "args": {"contents": "($1)$0"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|;|\\}|$)", "match_all": true }
]
},
方括号、大括号以及单引号和双引号也类似。
Ctrl + PgUp Cycle up through tabs
Ctrl + PgDn Cycle down through tabs
这可以到括号的末尾