keyboard-shortcutssublimetextucfirst

Sublime Text - command to make first character uppercase


There are upper_case and lower_case commands:

{ "keys": ["ctrl+k", "ctrl+u"], "command": "upper_case" },
{ "keys": ["ctrl+k", "ctrl+l"], "command": "lower_case" },

I'm searching for command to capitalize the first letter of string, which can be assigned to custom shortcut.


Solution

  • Under Edit -> Convert Case is the Title Case option. The following key binding should work:

    { "keys": ["ctrl+k", "ctrl+t"], "command": "title_case" }
    

    Add this to your custom keymap, and it will override the default command for CtrlK,CtrlT - fold_tag_attributes. Alternatively, you can use

    { "keys": ["ctrl+k", "ctrl+i"], "command": "title_case" }
    

    which is not assigned to anything in the default Sublime keymap.

    If you're interested in other types of conversions, check out the Case Conversion plugin on Package Control. It installs commands for snake_case, camelCase, PascalCase, dot.case, and dash-case, along with a few other utilities, such as a function to separate words with slashes.