VI Editor 6'th Edition

Page 84

[:graph:]

Printable and visible (non-space) characters

[:lower:]

Lowercase characters

[:print:]

Printable characters (includes whitespace)

[:punct:]

Punctuation characters

[:space:]

Whitespace characters

[:upper:]

Uppercase characters

[:xdigit:]

Hexadecimal digits

You will have to do some research to determine if you have this facility in your version of vi. You may need to use a special option to enable POSIX compliance, have a particular environment variable set, or use a version of vi that is in an unusual directory. vi on HP-UX 9.x (and newer) systems support POSIX bracket expressions, as does /usr/xpg4/bin/vi, on Solaris (but not /usr/bin/vi). This facility is also available in nvi, and in elvis 2.1. As commercial UNIX vendors become standards-compliant, expect to see this feature become more widespread.

6.3.3 Metacharacters Used in Replacement Strings When you make global replacements, the regular expressions above carry their special meaning only within the search portion (the first part) of the command. For example, when you type this: :%s/1\.

Start/2.

Next, start with $100/

note that the replacement string treats the characters . and $ literally, without your having to escape them. By the same token, let's say you enter: :%s/[ABC]/[abc]/g If you're hoping to replace A with a, B with b, and C with c, you'll be surprised. Since brackets behave like ordinary characters in a replacement string, this command will change every occurrence of A, B, or C to the five-character string [abc]. To solve problems like this, you need a way to specify variable replacement strings. Fortunately, there are additional metacharacters that have special meaning in a replacement string. \

n


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.