Reputation: 815
I have a file in the following format
--Some-XYZ-code ;
--Somemore--xyz--code;
COMMENT = " THIS IS A DEMO"
--somemore--code;
--somemore--code;
I want to put an semicolon at the end of line COMMENT, keeping the rest of the line intact.
Upvotes: 4
Views: 294
Reputation: 36252
Try this:
:g/^COMMENT/ normal A;
For every line that matches COMMENT
at the beginning enter in Insert Mode at the end of the line and append a semicolon.
Explanation: :g
selects every line that matches following pattern ^COMMENT
and does the action after last slash, normal A;
Upvotes: 8
Reputation: 198314
This should do it:
:g/COMMENT/norm A;
g
: globally on all lines matching /COMMENT/
,
norm
: execute normal command
A;
: of appending a semicolon to the end of the line.
Upvotes: 4