Use upper-case as word separator in Sublime Text 2 - 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.

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.

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.

Related

create Sublime2 key binding to mimic shift + arrowL/R

In Sublime2, when you hold down shift and use the L/R arrow keys, your cursor moves while selecting text characters. I want to map this behavior to something else with Sublime key bindings, so I don't have to move my hands to the arrow keys to do this really common action.
I can't figure out how to do this, or if it's possible. I want to do something like this:
{ "keys": ["super+k"], "command": "move_and_select", "args": {"by": "characters", "forward": true} },
{ "keys": ["super+j"], "command": "move_and_select", "args": {"by": "characters", "forward": false} },
But I've just made up the move_and_select command. If you use the command move, it moves left and right by a character, but I want to move and select.
Is this possible? Can it be done with a python script plugin?
Figured it out. set "extend": true in args to make the movement also select. So the correct answer should be:
{ "keys": ["super+j"], "command": "move", "args": {"by": "characters", "forward": false, "extend": true} },
{ "keys": ["super+l"], "command": "move", "args": {"by": "characters", "forward": true, "extend": true} },

Hotkey for cursor movement in windows sublime text

I use emacs and always use ctrl-n/p to move the cursor up/down one line.
My teammates use sublime text and they always use MOUSE!!
I googled a bit but can't find a keybinding of cursor-up/down in windows sublime.
How do you move your cursor in windows sublime?
Add the following to your user key bindings.
{ "keys": ["ctrl+n"], "command": "move", "args": {"by": "lines", "forward": false} },
{ "keys": ["ctrl+p"], "command": "move", "args": {"by": "lines", "forward": true} }
If you are an emacs user, you may also be interested in trying out https://github.com/grundprinzip/sublemacspro

ESC doesn't unselect my selection

It's impossible to unselect my selection by pressing ESC (It keeps the selection I had made)
I want that when I press ESC, that it unselects everything. Is this possible?
This behavior is present in Visual Studio too
VIKASH_DASH's answer is on the right track, but overriding Escape's functionality without context is going to hurt some feelings. Escape is a rather dignified key; take a look at Preferences -> Key Bindings – Default and you'll see that Escape has six important, er, escape-related functions. You definitely wouldn't want to overwrite all of them all of the time!
Thankfully, Sublime Text's keybindings can have contexts. Coupled with some sneaky usage of the move command (have you noticed that hitting Left or Right effectively deselects everything?) you can create a keybinding to add to Preferences -> Key Bindings – User that only executes if you have something selected and doesn't clobber Escape's other functions:
{ "keys": ["escape"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": false }
]
}
The "forward": true argument to the move command will move your cursor to the end of the current selection before deselecting (it will also split your cursor if you have multiple selections, just mash it again to escape from that as well!). To move to the beginning instead, change "forward": true} to "forward": false}. Instead of acting almost exactly like Right, Escape is now a glorified Left!
There is a nice deselect package -
it doesn't move the cursor
its in In
preferences->key bindings usr ..
use put these code hope its works;
[
{ "keys": ["escape"], "command": "move_to", "args": {"to": "eof", "extend": false} },
]

Opposite of "wrap selection with tag" in Sublime Text 2

Is there a smarter way of removing the tag (let's say using HTML) around a selection in Sublime text 2?
For example if I have a span tag around some text and want to remove both the start and end of this tag (and leave the text inside untouched)...
Or alternative - remove current tag and it's corresponding end tag?
The Emmet plugin (once called Zen Coding) can do what you want. Install it and press Ctrl+Shift+; within a tag's contents to unwrap the tag.
A bit easier way to do this is to use a macro:
unwrap.sublime-macro
[
{
"args":
{
"to": "tag"
},
"command": "expand_selection"
},
{
"args": null,
"command": "copy"
},
{
"args":
{
"to": "tag"
},
"command": "expand_selection"
},
{
"args": null,
"command": "paste_and_indent"
}
]
...with a ctrl+u for example:
{
"keys": ["ctrl+u"],
"command": "run_macro_file",
"args": {"file": "res://Packages/User/unwrap.sublime-macro"}
}
Pros: no plugins required, only default ST functionality. Cons: modifies clipboard data.

Sublime text 2 vintage mode disable ctrl+[

I recently started using Vintage mode in Sublime Text 2. I also enable Ctrl Keys support by adding "vintage_ctrl_keys": true in my configuration file.
However, this affect my workflow because I am using ctrl+[ and ctrl+] for indentation. Vintage mode basically remap ctrl+[ as escape.
Is there an easy way to disable ctrl+[ mapping in vintage mode ? I am still using ctrl+f and ctrl+b for scrolling.
You could disable vintage_ctrl_keys and set key bindings for Ctrl+F and Ctrl+B for page scroll:
{ "keys": ["ctrl+b"], "command": "move", "args": {"by": "pages", "forward": false} },
{ "keys": ["ctrl+f"], "command": "move", "args": {"by": "pages", "forward": true} }