Sublime Forum

Capitalization does not work for new line

#1

I raised a question here about capitalizing the first letter after a period (".") in Latex. It worked.

Now, I am adapting it to apply this function to markdown files and also want it to capitalize the first letter after “?” and “!”. I made changes in the following:

  1. from { "key": "selector", "operator": "equal", "operand": "text.tex.latex" } to { "key": "selector", "operator": "equal", "operand": "text.html.markdown" }, and
  2. from { "key": "preceding_text", "operator": "regex_contains", "operand": "(?:^|\\.)\\s+$" } to { "key": "preceding_text", "operator": "regex_contains", "operand": "(?:^|\\.|\\?|\\!)\\s+$" }

It works and capitalize the first letter right after “.”, “?”, and “!”. However, it did not capitalize the first letter in the new line, probably because the “?:^” does not match new line in markdown files, I guess. I would appreciate it if someone can fix it. Thanks.

0 Likes

#2

Hey, complete newbie here, but as far as I know regex is regex, independently of scope. Did you try to substitute the “+” for a “*”?

{ "key": "preceding_text", "operator": "regex_contains", "operand": "(?:^|\\.|\\?|\\!)\\s+$" }

to

{ "key": "preceding_text", "operator": "regex_contains", "operand": "(?:^|\\.|\\?|\\!)\\s*$" }

Let me know if that works.

0 Likes

#3

It worked in some ways, but it also capitalizes words like i.e. to i.E., which is not necessary. A solution is found [here] (Capitalizing the first letter after punctuation)

0 Likes