wincent / scalpel

🔪 Fast within-file word replacement for Vim
MIT License
118 stars 4 forks source link

What bad things may happen? #13

Closed subnut closed 3 years ago

subnut commented 3 years ago

be aware that whatever changes you make to the command-line prior to pressing must keep it a valid pattern, or bad things will happen

What bad things may happen? Some examples?

wincent commented 3 years ago

Well, it just means Scalpel doesn't do anything to check that you supplied a valid pattern; it will just pass it blindly on to Vim, and Vim will complain.

eg. if you do :Scalpel/\v[// (ie. [ with no balancing ]), Vim will explode:

Error detected while processing function scalpel#substitute[29]..<SNR>148_replacements:
line    4:
E486: Pattern not found: \v[//gce#
Error detected while processing function scalpel#substitute:
line   29:
E171: Missing :endif

It's as though you'd typed :%substitute/\v[//g directly, which would do this:

E486: Pattern not found: \v[//g

You can see that error buried in the middle of the output from Scalpel.