Previous Topic | Table of Contents | Next Topic

Substitution Modifiers

Substitution modifiers can be applied to any command, variable or history substitution. Also, any number in a row can be applied, as desired.

Operator
Meaning
:n nth word
:# Count the number of words
:^ Word number 1, counting from 0
:$ Last word
:% Word matched by a !?str? history search
:n-m nth through mth words
:-n 0 through nth words
:n- nth through next-to-last words
:n* nth through last word
:* 1 through last word
:q Single-quote each word
:s/str1/str2/ Substitute str2 for str1 and then reparse into words. Match failures are considered to be errors unless ignoreerrors == 2.
:S/str1/str2/ Substitute str2 for str1 but leave it as a single string. Also, failure to match is not considered an error.
:& Repeat last substitution
:g Global editing: as a prefix character to any of the other editing operators, it means apply the edit operation everywhere it matches, not just the first occurrence.
:x Treat each word as a string, break it up into words, then single-quote each word.
:p Print the substitution but don't execute the statement. (Ignored except in history substitutions.)



Previous Topic | Table of Contents | Next Topic

Copyright © 1988-2003 by Hamilton Laboratories. All rights reserved.