perl - VIM 7.2 Scripting problem with `:perldo` and multiple expressions -
background work
To end XY issues, I would say what I'm doing: I is trying to use : perldo
in VIM 7.2 to complete two tasks:
- Clear all the backward whitespace, in which (not clearing ) The removal lines are only white space
-
s / \ s + $ //;
- Before non-non-space characters
-
s / ^ (\s *) (? = \ S) / S # [^ \ t] ## g; $ _ / Xe;
I want to do all this one pass right now, by using
: perldo
I can work with two passes. (Using: twice daily)The command should look like this:
: perldo s / \ s + $ //; S / ^ (\ s *) (? = \ S) / s # [^ \ t] ## g; $ _ / Xe;
pearl background
To understand this problem you should know something about Perl
s ///
automatically defaults The variable binds the variable$ _
which is free to modify the regedx. Most of the main functions work on default at$ _
.perl -e '$ _ = "foo"; S / foo / bar /; S / bar / baz /; The impression is that you can use the expression in the VIM using the
# print: perldo
and it is logical to print the 'baz
Will work as usual.
Vime is not good
Now my VIM problem has been improved with the code - I've reduced it in a simple test. Open a new buffer, place the following text in it:
aa bb aa bb
to run it now
: perldo s / a / z /; S / b / z /;
buffer is now in:za zb aa zb
the second regox failed row, and yet another regex was successful by itself , And on the first line?
-
It appears that the entire parall expression that passes through : perldo A true / defined value must be returned, or the results are removed, per-line
try it, nothing happens on any line:
: Perldo s / a / z /; S / b / z /; 0
Try it, it works on all 3 lines as expected:
: perldo s / a / z /; S / b / z; An example in 1
: perldo
indicates:
: perldo $ _ = reverse ($ _) ; 1
But unfortunately it does not say clearly what is happening.
Comments
Post a Comment