With the block selected, use this substitute:
s/=.*$/= NULL;
The substitution regex changes each line by replacing anything between =
and the end of the line, including the =
, with = NULL;
.
The first part of the command is the regex matching what is to be replaced: =.*$
.
- The
=
is taken literally.
- The dot
.
means any character.
- So
.*
means: 0 or more of any character.
- This is terminated by
$
for end of line, but this actually isn't necessary here: try it also without the $
.
So the regex will match the region after the first =
in each line, and replace that region with the replacement, which is = NULL;
. We need to include the =
in the replacement to add it back, since it's part of the match to be replaced.
When you have a block selected, and you hit :
to enter a command, the command line will be automatically prefixed with a range for the visual selection that looks like this:
:'<,'>
Continue typing the command above, and your command-line will be:
:'<,'>s/=.*$/= NULL;
Which will apply the replacement to the selected visual block.
If you'll need to have multiple replacements on a single line, you'll need to add the g
flag:
:'<,'>s/=.*$/= NULL;/g