Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use upper-case as word separator in Sublime Text 2

Tags:

sublimetext2

I can't find out how to use upper-case letters as word separators in Sublime Text 2.

What I want is the following behaviour: in some C++ IDE I like, using ctrl+left/right when cursor is in a word like thisIsAComposedWord will move cursor to next upper case in the word (or to the beginning/end of the word).

There's something in Sublime text called "word separators" that seems to do that, it appears his way in the default preferences file:

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

So can I insert upper-case in that list? Thanks.

like image 331
Mathias Avatar asked Apr 09 '13 15:04

Mathias


2 Answers

You can move by "Subword" with the following Keybinds:

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

This recognizes camelCase and under_score.

You can also move by Word with

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

This recognizes "word separators" as specified in your settings file.

like image 101
Dagoth Ulen Avatar answered Oct 15 '22 10:10

Dagoth Ulen


I'm using Sublime Text in Linux (Ubuntu) and this works for me:

In your Settings-User add the same content of the "word-separators" by default (which is that you put in the question). Then, to the string add the regular expression of a Upper-Case letter [A-Z]. The result is:

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

In order to move to the next upper case in a Word, I use Alt + Left/Right arrow.

Edit:

Regular expression doesn't work. The answer is not valid.

like image 1
Rodri_gore Avatar answered Oct 15 '22 11:10

Rodri_gore