Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 914
luthfianto Avatar asked Mar 01 '15 05:03

luthfianto


People also ask

How do you capitalize the first letter in Sublime Text?

One of the most popular code and text editors, Sublime Text also includes a capitalization tool. Just select your text, click the Edit menu, and select Convert Case followed by the case you want.

What is the case when the first letter is capitalized?

Capitalisation is the writing of a word with its first letter in uppercase and the remaining letters in lowercase. Capitalisation rules vary by language and are often quite complex, but in most modern languages that have capitalisation, the first word of every sentence is capitalised, as are all proper nouns.

What is it called when you capitalize the first letter of every word?

CamelCase Words are written without spaces, and the first letter of each word is capitalized. Also called Upper Camel Case or Pascal Casing. lowerCamelCase A variation of Camel Case in which the fist letter of the word is lowercase, e.g. iPhone, iPad, etc.


2 Answers

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>
like image 69
Paul Chris Jones Avatar answered Oct 27 '22 01:10

Paul Chris Jones


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.
like image 27
sergioFC Avatar answered Oct 27 '22 01:10

sergioFC