Sublime Forum

Key binding for 'Swap Case'...?

#1

I would really like to add a key binding for swapping/changing the case of the selected text. I don’t see an expose command to access this, even though it is in the edit menu.

Is there a long term plan to expose all or most of the menu items as commands for keybinding or possibly another method of accessing menu items as bindable actions?

Thanks,
Greg

P.S. Sublime rocks!

0 Likes

#2

They are all there available to your disposal so you can abuse all the commands you want :smiley:
Everything that there is in the MAIN MENU (top menu) are located in the Main.sublime-menu file

Location: %appdata%\sublime text\packages\default\Main.sublime-menu

and to answer the question just for the hell of it,

<item caption="&amp;Swap Case" command="swapCase"/>

BONUS: if you want to add anything to the “right click” (context) menu then the file is: Context.sublime-menu same location above.
If you want to add anything to the TAB right click menu the file is Tab Context.sublime-menu

Just remember that any changes to these files will get lost when you upgrade, so if you do change it, whenever u update have that in mind :smiley:

0 Likes

Rename a file you have open
#3

Sweet! Guess I just needed to dig further…

Thanks!

0 Likes

#4

My new sweet context menu!


0 Likes

#5

If somebody needs toggle case command here is a quick addon to Packages/Default/transform.py

class ToggleCaseCommand(Transformer):
    transformer = lambda text: text.lower() if text:1].istitle() else text.upper(),

The code checks if the first letter of the selected text is uppercase then it makes it all lowercase and the opposite.

Cheers

0 Likes

#6

You can try this

{ "keys": "ctrl+shift+x"], "command": "swap_case" }

thanks Gabe
Sublime Text Shortcuts for Writing

0 Likes