If you want to change all content to become sentence case. I wrote a script as follows:
#turn all to lower
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
#change first letter of first line to upper
1 {
/^[a-z][^.]*.*$/ {
h
s/^\([a-z]\).*$/\1/
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
G
s/^\(.*\)\n\([a-z]\)\(.*\)$/\1\3/
}
}
#turn any word after full stop to upper
:loop
/\. [a-z]/ {
h
s/^[^.]*\(\. [a-z]\).*$/\1/
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
G
s/^\(\. [A-Z]\)\n\(.*\)\(\. [a-z]\)\(.*\)$/\2\1\4/
b loop
}
# if full stop appears in last position, change letter to upper in next line
/[a-z]\{2,\}\.$/ {
n
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
/[a-z][^.]*.*$/ {
h
s/\([a-z]\)\(.*\)/\1/
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
G
s/\(.*\)\n\([a-z]\)\(.*\)/\1\3/
b loop
}
}
#Should do this replacement in last part of the script
/^$/ {
n
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
/^[a-z][^.]*.*$/ {
h
s/^\([a-z]\).*$/\1/
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
G
s/^\(.*\)\n\([a-z]\)\(.*\)$/\1\3/
b loop
}
}
Hope it may be useful for you. If it can't handle any cases pls. let me know.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.