I'm looking for a script that would check the beginning of a paragraph and first character after sentence's terminal (.,?,!), and then it would capitalize required letters.

Thank you for help.

link|improve this question

I'd suggest you additionally require a space after the terminal (hxxp://www.Google.Com). Still not perfect (Yahoo! employees), but fewer false positives. – Daniel Beck Jan 15 '11 at 12:50
feedback

1 Answer

up vote 2 down vote accepted

Give this a try:

%s/\(^\|[.?!] \+\)./\U&/g

Explanation:

`%` - for every line in the file
`s/` - substitute
`\( \| \)` - a group of alternatives
`^` - after a newline (beginning of paragraph)
`[.?!] \+` - after a terminal punctuation mark and one or more required spaces
`.` - any character (it's not necessary, but you could use `[[:alpha:]]` instead)
`/` - replacement
`\U` - uppercase the following string (it will only affect the `[[:alpha:]]` character
`/g` - end of command and make it apply to every match on a line
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.