Monday, January 28, 2008

Using Perl

If your install of Vim was built with an embedded Perl interpreter, you can leverage the power of the language to your advantage. I typically use the embedded Perl interpreter to add the power of Perl's regular expressions to Vim. Say you're editing a file, you make a selection in visual mode, and you want to substitute all digits with the `x' character. This is easily accomplished using the perldo ex command.

:perldo s/\d/x/g

See http://perldoc.perl.org/perlre.html and :help perldo for more information.

No comments: