|
WareLogging, VimEditor, PerlLanguage.
|
|
|
|
= perl compatible regular expressions =
|
|
|
|
[http://vim.sourceforge.net/tips/tip.php?tip_id=393 Perl compatible regular expressions]. For most of the one-off expressions you'll ever write, there's a way to do what you want in vim. That said, if you're used to Perl, translating between the two dialects becomes painful for anything much beyond a simple search and replace. Instead:
|
|
|
|
# Verify in :ver that +perl or +perl/dyn is compiled in.
|
|
# Install Perl if necessary. On Windows, ActivePerl is required.
|
|
# Type :perldo s/searchme/replaceme/g
|
|
|
|
Or:
|
|
|
|
:%!perl -pi -e 's/<text>/\n/'
|
|
|
|
On Debian, you can
|
|
|
|
apt-get install vim-perl
|
|
|
|
<[Brennen]> When using perldo to perform substitutions, keep in mind that $_ is set to the current line ''without'' a newline - so if you're expecting whitespace at the end of the line, you may not find it.
|
|
|
|
This works, though:
|
|
|
|
:perldo s/(http\S+?)(\s|$)/"$1"$2/g
|
|
|
|
Note the (\s|$).
|