Reputation: 10507
I've got this python-like text:
if a==0:
print ok
[1:]xy
I wish to delete all "[1:]" content. So I tried this:
%s/[1:]//g
Unfortunately, the first line is changed to be
if a==0
The ":" was eliminated, not as my expectation. So how should I do?
Upvotes: 0
Views: 47
Reputation: 2946
Vim search uses regular expressions to match, [
and ]
are special characters in regex to match sets of characters.
[1:]
means 1
or :
. You need to escape the brackets like: %s/\[1:\]//g
Upvotes: 4