0

Hello I want to add # at the beginning for few lines where content like /vol/home12 & vol/home14, line number not in sequence so I want to change with global option for file instead of going with sequence number

1 Answers1

0

A standard vi may not support alternation in regex, so two commands may be needed:

:g/\/vol\/home12/s/^/#/
:g/vol\/home14/s/^/#/

With vim, alternation (\|) can be used:

:g/\/vol\/home12\|vol\/home14/s/^#/

General form is: :g/RE1/cmd

This applies cmd to each line that matches RE1.

Here, cmd is: s/RE2/str/

RE2 is ^, which matches start of line.

jhnc
  • 167