Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|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
up vote 2 down vote accepted

Give this a try:

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


`%` - 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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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