You can filter any line or range of lines through an external command in vim, using !. E.g., you can do:
:.!perl -pe "s/(\w+)/\u\1/g"
which will filter the current line through that perl command. ( Here
: to get into command line mode, and the
. which follows mean the current line; you can also specify a line range or
% for the whole file, etc.)
If you want to use vim’s built in substitution patterns, the closest you’ll come is to use vim’s “very magic” option, \v, like so:
:help pattern and
:help substitute for more details. I don’t think “very magic” is quite identical to perl’s patterns, but is very close. Anyway, you can always use perl itself if you’re more comfortable with it, as above.
You can also use:
No, you can’t use Perl regular expressions in that way. For help in learning the Vim equivalents for Perl regular expression components, see
However, you can use Perl as an external filter as explained by frabjous. You can also execute Perl commands within Vim using the Perl interface, if your Vim was compiled with the
+perl feature. See
Here’s a solution from http://vim.wikia.com/wiki/Perl_compatible_regular_expressions
+perl/dyn is compiled in.)