简体   繁体   中英

Sublime: How to select by single word in CamelCase variable?

Disclaimer

I apologize ahead of time if this has already been answered elsewhere, but I had little success in finding one. Please feel free to redirect me to another stackoverflow post!

Example

var CamelCasedVariable;
//  ^Cursor is here (to the left of 'C')

Using Mac OS, Shift + Cmd + Right Arrow starting at the specified location in Sublime highlights all of CamelCasedVariable .

The Question

How do I make a single execution of that command only highlight Camel ? Or perhaps there is another keyboard shortcut or package that does this?

Any help would be appreciated. Thanks!

The internal command that does this is the move command with a by argument of subwords or subword_ends (depending on which direction you're moving).

The default key bindings for that are Alt+Left and Alt+Right on Windows and Linux and Ctrl+Left and Ctrl+Right on MacOS. Additionally MacOS also has the same commands bound to Ctrl+Alt+Left and Ctrl+Alt+Right , which is probably because on an least some Macbooks the versions without Alt move between virtual desktops (this may be configurable in MacOS though).

That will give you the subword navigation that you want; include the Shift key in them to also extend the selection.

These key bindings will be visible in the left hand pane of the window you get when you select Preferences > Key Bindings from the menu; you can search for subwords to see the full bindings, should you want to change them by adding them to your own custom bindings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM