Search code examples
sublimetext2sublimetextsublimetext3

Sublime text: How to do sentence case (capitalize the first letter of a sentence)


I'm aware that there is Edit > Change Case menu. But there's no option for sentence case.

How do I achieve this? Is this possible for regex to achieve this?


Solution

  • You can use this regex:

    find

    (^|\.\s|…\s)([a-z])
    

    and replace with

    \1\u\2
    

    Explanation:

    1. The first find group (parénthesis group) captures a line beginning or a dot followed by a space or three dots character followed by a space.
    2. The second group captures a letter.
    3. In the replace expresion \1 and \2 refer to the captured groups.
    4. \u means translate one character to uppercase.
    5. This capitalizes lines starting with a character and sentences starting after other sentences.