11

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?

luthfianto
  • 1,746
  • 3
  • 22
  • 37

3 Answers3

17

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.
celiker
  • 875
  • 7
  • 15
sergioFC
  • 5,926
  • 3
  • 40
  • 54
1

Find:

<h4>(.)(.*)</h4>

Replace:

<h4>\u\1\L\2</h4>

That would make

<h4>This Is A Demo</h4>

into

<h4>This is a demo</h4>
Paul Chris Jones
  • 2,646
  • 1
  • 23
  • 21
-2

It is a possible duplicate of Sublime Text - command to make first character uppercase.

By the way, in brief, you could use the key-map CtrlK,CtrlI, writing in your "user keybinding file":

{ "keys": ["ctrl+k", "ctrl+i"], "command": "title_case" }
Community
  • 1
  • 1
Giacomo Paita
  • 1,411
  • 2
  • 12
  • 21