39

我需要一种快速的方法来使光标跳到自动换行 qoutes 或其他语法元素之外。我不想每次都必须向下按箭头键,并且绝对不想去我的鼠标。

在此处输入图像描述

有没有一种快速简便的方法可以为我的工作流程解决这个问题?

4

12 回答 12

60

您可以使用快捷方式(shift+space或任何您喜欢的方式)来移动光标。

在你的Key Bindings - User

{ "keys": ["shift+space"], "command": "move", "args": {"by": "characters", "forward": true} }
于 2013-02-10T18:15:26.790 回答
15
于 2013-12-29T07:46:47.427 回答
9

最好的解决方案是在 Sublime Text 上录制宏,然后将其分配给键盘快捷键。按着这些次序:

  1. 创建一行如 alert('hello') 并将光标留在字母 'o' 之后。
  2. 然后转到工具 > 录制宏开始录制。
  3. Command+→</kbd> to go to the end of line.
  4. 按下;并击中Enter
  5. 通过转到工具 > 停止录制宏来停止录制宏
  6. 您现在可以通过工具 > 播放宏(可选)测试您的宏
  7. 通过转到工具 > 保存宏来保存您的宏(例如:EndOfLine.sublime-macro)
  8. 通过在您的首选项 > 键绑定 - 用户文件中的方括号之间添加此快捷方式来创建快捷方式:

    {
    "keys": ["super+;"], "command": "run_macro_file", "args": {"file": "Packages/User/EndOfLine.sublime-macro"}
    }
    
  9. 现在,每次你点击Command+;时,它都会神奇地将分号放在当前行的末尾并将光标移动到下一行。

快乐编码!

于 2013-08-10T19:54:15.523 回答
5

进行键绑定的更完整方法是:

    { "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

于 2015-10-14T18:59:31.977 回答
3

继 Riccardo Marotti 的帖子之后;

如果您想绕过下一行的括号,可以在 args 部分将“characters”替换为“lines”。

{ "keys": ["shift+space"], "command": "move", "args": {"by": "lines", "forward": true} }
于 2013-06-11T22:15:59.450 回答
2

在戴尔 XPS 上,Ctrl Enter 对我有用

于 2013-06-02T01:03:22.543 回答
2

我只是在名为 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. 光标就在打开括号/括号之前:

    移动到右括号/括号

  4. 1&& !2&& !3

    移动到右括号/括号

    再向前移动一个角色

run_multiple_commands.py要在你的ST中使用这个配置,首先要在你的目录下添加一个名为的文件.../Package/User/,其内容是本文第二段代码

该解决方案适合日常使用,但并不完美,因为:

  1. 光标无法跳出引号(当光标直接跟随一个时,只需跳过它)。
  2. 注释代码块时,光标无法跳出最近的括号、引号或方括号。
于 2013-10-03T21:50:54.507 回答
2

Ctrl + M 是我在 Windows 机器上的默认设置。去做就对了

于 2017-04-18T06:39:45.653 回答
1

也许homeend键就在您的手指附近。

于 2013-02-10T18:07:25.840 回答
1

我使用ctrl+f将光标向前移动一格。此外,在 mac 上,我caps lockctrl. caps lock+f更容易到达。它对我来说效果很好。

于 2013-05-16T07:43:31.530 回答
1

我发现了另一种方式,它位于崇高的键绑定本身。基本上,我只是修改了自动关闭括号的键绑定,也就是说,我"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 }
    ]
},

方括号、大括号以及单引号和双引号也类似。

于 2017-06-12T02:12:30.507 回答
0
Ctrl + PgUp Cycle up through tabs

Ctrl + PgDn Cycle down through tabs

这可以到括号的末尾

于 2013-06-11T03:05:12.600 回答