Need easy way to make first letter of each line upper case

1,049 views
Skip to first unread message

Nosadge

unread,
Oct 28, 2021, 7:01:59 PM10/28/21
to BBEdit Talk
Hello,

Does anyone know a command/script/grep to make sure the first letter of every line is capitalized?

Fletcher Sandbeck

unread,
Oct 28, 2021, 8:48:11 PM10/28/21
to bbe...@googlegroups.com
Find "^(.)" and replace with "\U\1". Make sure Grep is checked in the find/replace dialog. The ^ matches the start of a line so the . matches the first character, surrounded by parentheses so we can refer to it in the replacement pattern. The replacement uses \U to make it uppercase.

[fletcher]


On Oct 28, 2021, at 3:10 PM, Nosadge <rjsu...@gmail.com> wrote:

Hello,

Does anyone know a command/script/grep to make sure the first letter of every line is capitalized?

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/2ac9fbb2-20da-46d9-9b1d-8716fff9bdd1n%40googlegroups.com.

Satomi Yoneki

unread,
Oct 28, 2021, 9:27:30 PM10/28/21
to bbe...@googlegroups.com
Hello Nosadge,

> Does anyone know a command/script/grep to make sure the first letter
> of every line is capitalized?

Have you tried Text > Change Case > Capitalize Lines ?

Regards,
Satomi

Tom Robinson

unread,
Oct 28, 2021, 10:15:11 PM10/28/21
to BBEdit Talk

> On 2021-10-29, at 14:15, Satomi Yoneki <satomi...@gmail.com> wrote:
>
>> Does anyone know a command/script/grep to make sure the first letter of every line is capitalized?
>
> Have you tried Text > Change Case > Capitalize Lines ?

That also converts any remaining uppercase in the line to lowercase.

Satomi Yoneki

unread,
Oct 28, 2021, 10:35:04 PM10/28/21
to bbe...@googlegroups.com
>> Have you tried Text > Change Case > Capitalize Lines ?
>>
> That also converts any remaining uppercase in the line to lowercase.
>
Yes.  The usage of this command is limited, but it works for a certain case.


Christopher Stone

unread,
Oct 28, 2021, 10:42:22 PM10/28/21
to BBEdit-Talk
On Oct 28, 2021, at 17:10, Nosadge <rjsu...@gmail.com> wrote:

Does anyone know a command/script/grep to make sure the first letter of every line is capitalized?


Hey There,

How are you defining lines?

Line one.
Line two.
...

In that case Fletcher's regex works fine, although you might prefer to run it from a script.



#!/usr/bin/env perl -sw

while (<>) {
    s!^.!\U$&!;
    print;
}



See the section on Text Filters in the BBEdit Manual, if you don't know how to run one.

~/Library/Application Support/BBEdit/Text Filters/



Or did you mean sentences?


--
Best Regards,
Chris

Nosadge

unread,
Oct 28, 2021, 11:29:27 PM10/28/21
to BBEdit Talk
Hey Fletcher,

Thanks so much!  I'll give that a shot tomorrow on my next project.  Thank you for the detailed explanation.

Nosadge

unread,
Oct 28, 2021, 11:29:27 PM10/28/21
to BBEdit Talk
Hey Chris!

I'm defining lines as anything with a number infant of it.  I'm new to this editor, and use it to edit transcripts, so my jargon will probably be incorrect.

I'm going to try Fletcher's suggestion on my next project.

Thanks for your input, and for guiding me to the right place in the manual!

Nosadge

unread,
Oct 28, 2021, 11:29:27 PM10/28/21
to BBEdit Talk
Thank you, Satomi!

Yep, I tried that before posting my question here.  Like Tom said, it changed all my upper case sentences to lower case! :-0

Nosadge

unread,
Oct 28, 2021, 11:35:28 PM10/28/21
to BBEdit Talk
Yep, found that out the hard way before posting my question here! :-D

Thanks for your reply, Tom!

Christopher Stone

unread,
Oct 28, 2021, 11:51:58 PM10/28/21
to BBEdit-Talk
On Oct 28, 2021, at 22:28, Nosadge <rjsu...@gmail.com> wrote:

I'm defining lines as anything with a number infant of it.  I'm new to this editor, and use it to edit transcripts, so my jargon will probably be incorrect.


Hey Nosadge,

Did you mean a number in front of the line?

If so will the number always be at the beginning of the line, or might it be indented?

Will the number have punctuation?

Can you provide an example that includes all the possibilities?

Parsing text is pretty exacting.


--
Best Regards,
Chris

Nosadge

unread,
Oct 29, 2021, 12:09:59 AM10/29/21
to BBEdit Talk
Hey Chris,

I meant the number of the line, as in the numbers in the left hand column.

The lines typically look like this: "so, it was...." Or, " so, it was...."  Which is something else I'd like to have a Grep for: removing spaces at the beginning of all lines.

My apologies for the misunderstanding.

Iain

unread,
Oct 29, 2021, 7:02:46 AM10/29/21
to BBEdit Talk
If you open up the Find/Replace and use this grep in the find box:

^(\w)

and this replacement in the Replace box:

\U\1\E

and then you can do Replace All

If you want to include the start of sentences that may have spaces in front of them (like the classic indent for a paragraph), you can use:

^(\s*)(\w)

and:

\1\U\2\E

Hope that answers your question. As to terminology, I think you're right to use "line" where the editor would show a line number to the left in the gutter, and "sentence" for a line that corresponds to grammar, e.g. a starting capital letter all the way to a fullstop.

Regards,
iain

Satomi Yoneki

unread,
Oct 29, 2021, 7:02:59 AM10/29/21
to bbe...@googlegroups.com

> I meant the number of the line, as in the numbers in the left hand column.
Those numbers are Line Numbers.
> The lines typically look like this: "so, it was...." Or, " so, it
> was...."  Which is something else I'd like to have a Grep for:
> removing spaces at the beginning of all lines.
Please try this.
Find: "^ +", which will search for one or more space characters at the
beginning of each line.
Replace: "" (empty)

If this does not delete spaces, maybe the text contains other invisible
characters.
You can select them and see what they are with Window > Palettes >
Character Inspecter.


David G Wagner

unread,
Oct 29, 2021, 10:48:55 AM10/29/21
to bbe...@googlegroups.com
You replace the ^ + with ^\s+ which would handle both spaces and tabs if there… ;)

Wags ;)
WagsWorld
Hebrews 4:15
Ph(primary) : 408-914-1341
Ph(secondary): 408-761-7391
--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.

Nosadge

unread,
Nov 1, 2021, 8:38:39 AM11/1/21
to BBEdit Talk
Hello Everyone!

Thanks to your recommendations and help, I am now able to replace all lower case letters at the beginning of lines AND remove spaces at the beginning of lines!

Your help will save me a tremendous amount of time and tedium each week!

"15 minutes invested one time (researching this in this forum), will save me 20 minutes thousands of times."

Thanks again!

I hope you're all able to see my thank you in this thread :-)
Reply all
Reply to author
Forward
0 new messages