Sublime Text 2 向上/向下箭头移动键绑定

发布于 2024-12-19 18:53:13 字数 586 浏览 1 评论 0原文

当我在 Sublime Text 2 上有一行文本时,假设我有“test”行。 如果插入符号位于“e”和“s”之间,并且我按向上按钮,则不会执行任何操作。 我想改变这一点,所以如果当前行上方没有行,当我按下时,插入符号应该转到行的开头。

与向下按钮相同。 如果当前行之间没有行,则插入符号应移动到行尾。

这是默认的文本伙伴行为,我经常使用它。

我可以用键绑定在 Sublime Text 2 上更改它吗? 我知道它应该是这样的:

{ "keys": ["up"], "command": "move", "args": {"by": "characters", "forward": false } ,“上下文”:
[
{ "key": "something", "operator": "not_regex_contains", "operand": "\n" }
] }

我找不到合适的上下文。我尝试了 previous_text not_regex_contains "\n",但 previous_text 只返回当前行开头和插入符号之间的文本。

有什么想法吗?

谢谢。

when i have one line of text on sublime text 2, say I have the line "test".
if the caret is between 'e' and 's' and I press the up button, it doesn't do anything.
I would like to change that, so if there is no line above the current one, when I press up, the caret should go to the start of the line.

same with down button.
if there is no line between the current line, the caret should move to the end of the line.

that is the default textmate behavior, and I use it a lot.

can I change that on sublime text 2 with keybindings?
I know it should be something like this:

{ "keys": ["up"], "command": "move", "args": {"by": "characters", "forward": false }, "context":
[
{ "key": "something", "operator": "not_regex_contains", "operand": "\n" }
] }

I cannot find the right context for it. I tried preceding_text not_regex_contains "\n", but preceding_text only returns the text between the start of the current line and the caret.

any ideas?

thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青萝楚歌 2024-12-26 18:53:13

您不需要按键绑定来完成此操作。在 Preferences.sublime-settings 文件中添加以下行应该可以解决问题:

"move_to_limit_on_up_down": true,

终止逗号的原因是因为这些文件采用 json 格式,如果在此之后有条目,则需要用逗号分隔它们。作为参考,这里以我的 Preferences.sublime-settings 文件为例:

{
    "always_show_minimap_viewport": true,
    "caret_style": "phase",
    "color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
    "draw_minimap_border": true,
    "ensure_newline_at_eof_on_save": true,
    "font_size": 12,
    "highlight_line": true,
    "highlight_modified_tabs": true,
    "move_to_limit_on_up_down": true,
    "overlay_scroll_bars": "enabled",
    "show_tab_close_buttons": false,
    "tab_completion": false
}

您可以通过转到 Preferences > 来编辑此文件。设置 - Sublime 中的用户

You don't need a keybind to accomplish this. Adding the following line in your Preferences.sublime-settings file should do the trick:

"move_to_limit_on_up_down": true,

The reason for the terminating comma is because these files are in json, and if you have entries after this one, you'll need to separate them by comma. For reference, here's my Preferences.sublime-settings file as an example:

{
    "always_show_minimap_viewport": true,
    "caret_style": "phase",
    "color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
    "draw_minimap_border": true,
    "ensure_newline_at_eof_on_save": true,
    "font_size": 12,
    "highlight_line": true,
    "highlight_modified_tabs": true,
    "move_to_limit_on_up_down": true,
    "overlay_scroll_bars": "enabled",
    "show_tab_close_buttons": false,
    "tab_completion": false
}

You can edit this file by going to Preferences > Settings - User in Sublime.

北城孤痞 2024-12-26 18:53:13

这应该可以像您在最新的开发版本中所期望的那样工作 - http://www.sublimetext.com/dev

This should work as you'd expect in latest dev builds - http://www.sublimetext.com/dev.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文