我正在寻找一个脚本,它可以检查段落的开头和句子终端后的第一个字符(.,?,!),然后将所需的字母大写。
谢谢你的帮助。
答案1
尝试一下:
%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