Google

vi commands

vi commands

Contact:[email protected]

Global search and replace

    :10,25s/old/new/g      Substitute "old" string with "new" in lines 10,25
    :%s/^/     /           For all lines (% is "all lines"), replace the
begining of the line with 5 blanks
    :%s/^     //           For all lines, replace 5 blanks at beginning of
line with nothing
    :50,.s/Unix/UNIX/      For lines 50 to the current line (.), replace
"Unix" with UNIX, only the first occurrence in the line
    :50,.s/Unix/UNIX/g     Same as above only do it for all occurrences of
"Unix" in the lines
JasonALewis (2:53:16 PM): what is that command for jumping to a line?
GregCDoan (2:53:28 PM): :%s/old/new/g will replace the old with the new
GregCDoan (2:53:33 PM): for all lines
GregCDoan (2:53:37 PM): :#
GregCDoan (2:53:51 PM): :+# to jump that many lines


Back to the Index