Sublime text word_separator CamelCase

时间:2013-08-02 08:45:56

标签: sublimetext2 sublimetext sublimetext3

崇高文字word_separator是:

"word_separators": "./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}`~?",

我还想将CamelCase中的案例更改视为更改。有没有设置/方法来做到这一点?

(例如在FooBar ctrl + bck_space中应该只删除Bar。)

5 个答案:

答案 0 :(得分:46)

如果有人还在看这个......

在默认的键绑定中,您会找到:

{ "keys": ["ctrl+left"], "command": "move", "args": {"by": "words", "forward": false} },
{ "keys": ["ctrl+right"], "command": "move", "args": {"by": "word_ends", "forward": true} },
{ "keys": ["ctrl+shift+left"], "command": "move", "args": {"by": "words", "forward": false, "extend": true} },
{ "keys": ["ctrl+shift+right"], "command": "move", "args": {"by": "word_ends", "forward": true, "extend": true} },

{ "keys": ["alt+left"], "command": "move", "args": {"by": "subwords", "forward": false} },
{ "keys": ["alt+right"], "command": "move", "args": {"by": "subword_ends", "forward": true} },
{ "keys": ["alt+shift+left"], "command": "move", "args": {"by": "subwords", "forward": false, "extend": true} },
{ "keys": ["alt+shift+right"], "command": "move", "args": {"by": "subword_ends", "forward": true, "extend": true} },

使用alt + direction将移动“subwords”而不是“words”,这会考虑camelCase。我更喜欢超过默认值,所以我将alt +方向设置复制到我的用户键绑定中,并用ctrl替换alt的实例。 Voila,ctrl +方向由camelCase以及定义的单词分隔符移动。

此外,我不确定使用子词设置是否会考虑下划线,我总是将_添加到单词分隔符以确保。

答案 1 :(得分:4)

我认为这只能通过插件来完成,而不仅仅是通过更改Sublime Text的设置。

这个插件看起来很有希望:
https://github.com/jdc0589/CaseConversion

答案 2 :(得分:4)

使用alt只能用于移动,而不能用于删除,但我发现了一些效果很好的东西:

  

删除转发(alt +删除):

delete_subword.sublime-macro:
[
   {
      "command": "move",
      "args": {
         "by": "subwords",
         "extend": true,
         "forward": false
      }

   },
   {
      "args": null,
      "command": "left_delete"
   }
]
  

向后删除(alt +退格)

delete_subword_forward.sublime-macro:
[
   {
      "command": "move",
      "args": {
         "by": "subwords",
         "extend": true,
         "forward": true
      }
   },
   {
      "args": null,
      "command": "right_delete"
   }
]
  

将其保存到您的用户目录中。现在,你绑定这样的键:

{ "keys": ["alt+backspace"], "command": "run_macro_file", "args": {"file": "Packages/User/delete_subword.sublime-macro"} },
{ "keys": ["alt+delete"], "command": "run_macro_file", "args": {"file": "Packages/User/delete_subword_forward.sublime-macro"} },

Source

答案 3 :(得分:0)

vim模式中的

Alt + W在sublime text 3中为我工作,以遍历camelCase单词

答案 4 :(得分:0)

您可以尝试适应这种运动,并从此程序包中查看提供自定义运动代码的示例代码: https://github.com/robertcollier4/KeyboardNavigation
https://packagecontrol.io/packages/KeyboardNavigation

KeyboardNavigation-键盘移动以及选择和删除自定义分隔符。在连续边界之间快速导航。对于SublimeText。