Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!texsun!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.editors Subject: Re: Change cases in VI Message-ID: <110304@convex.convex.com> Date: 11 Dec 90 06:21:29 GMT References: <1990Dec11.005842.13795@pa.dec.com> Sender: news@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Distribution: na Organization: CONVEX Software Development, Richardson, TX Lines: 39 In article <1990Dec11.005842.13795@pa.dec.com> reader@wsl.dec.com (News Reader) writes: > >Is there an easy way to change the whole file from upper case to lower case or >vice versa? I don't want to do 26 substitutions to change character by >character. INTERNALLY: :%s/.*/\U&/ :%s/.*/\L&/ TOOLISHLY: :%!tr a-z A-Z # real unix :%!tr A-Z a-z :%!tr '[a-z]' '[A-Z]' # bad unix :-) :%!tr '[A-Z]' '[a-z]' :%!sed y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/ :%!sed y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ :%!gawk '{print tolower($0)}' :%!gawk '{print toupper($0)}' :%!nawk '{print tolower}' # nawk assumes $0, gawk doesn't :%!nawk '{print toupper}' :%!perl -pe y/a-z/A-Z/ # for sed folks :%!perl -pe y/A-Z/a-z/ :%!perl -pe tr/a-z/A-Z/ # for sh folks :%!perl -pe tr/A-Z/a-z/ --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "With a kernel dive, all things are possible, but it sure makes it hard to look at yourself in the mirror the next morning." -me