Sublime text word_separator CamelCase

ⅰ亾dé卋堺 提交于 2019-12-09 07:35:09

问题


The sublime text word_separator is:

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

I would also like case change in CamelCase to be considered change. Is there a setting/way to do this?

(Eg in FooBar ctrl+bck_space should delete only Bar).


回答1:


In the event anyone is still looking at this...

In your default keybindings you'll find:

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

Using alt+direction will move by "subwords" as opposed to "words", which takes into account camelCase. I prefer that over the default so I've copied the alt+direction set into my user keybindings and replaced the instances of alt with ctrl. Voila, ctrl+direction moves by camelCase as well as the defined word separators.

Also, I'm not sure if using the subwords setting will take into account underscores, I've always added _ to the word separators just to make sure.




回答2:


I think this can only be done via a plugin, not simply by changing Sublime Text's settings.

This plugin looks promising:
https://github.com/jdc0589/CaseConversion




回答3:


Using alt works only for moving, not for delete, but I found something that works pretty well:

Delete forward (alt+delete):

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

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

Delete backward (alt+backspace)

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

Save it into your User directory. Now, you bind keys like this:

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




回答4:


Alt + W in vim mode works for me in sublime text 3 to traverse camelCase words




回答5:


You can try to adapt this movement and see sample code from this package which provides custom movement code:
https://github.com/robertcollier4/KeyboardNavigation
https://packagecontrol.io/packages/KeyboardNavigation

KeyboardNavigation - Keyboard movement and selection and deletion to custom delimeters. Navigate fast between contiguous boundaries. For SublimeText.



来源:https://stackoverflow.com/questions/18012493/sublime-text-word-separator-camelcase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!