Scrapple from the Apple

rafael on 2003-01-16T10:36:45

I'm often amazed at how vim's regular expressions just Do What I Mean.

Do I want to search for all lines that begin with a star ? The simpler regexp that just-works is /^*/. No need to quote the star with a backslash. Ditto for dollars that don't appear at the end of a pattern: they match the litteral character $, not the end of line.

That's the right thing to do in a text editor, but I don't think that's the right thing in a general-purpose programming language.

Title of this journal entry by Charlie Parker.


VIM DWIM

gtod on 2003-01-16T11:06:26

Interesting you should say that. It must be the way my brain works (or doesn't work) but I've always struggled with Vim's Regex requirments.

Being reasonably competent in Perl 5 Regex syntax (thanks to Friedl's MRE) I just get annoyed at the differences I find in Vim and drop out and end up doing things in Perl.

I suppose I should read the Vim docs but I'm almost afraid that my brain just can't hold two Regex flavours at once without stopping all together...

Re:VIM DWIM

rafael on 2003-01-16T11:43:50

If you've read MRE, you know that there aren't two Regex Flavours. There are many more : I know at least the grep and the egrep/sed/awk ones.

There used to be a project (before vim 6 was out IIRC) to bring Perl 5-compatible regexps to vim (i.e. to write a translator Perl 5-style to vim-style.) It was dropped, but you can still write a patch and attempt to convince Bram Moolenaar (who isn't a Perl-addict like us...)

Re:VIM DWIM

broquaint on 2003-01-22T12:28:47

There used to be a project (before vim 6 was out IIRC) to bring Perl 5-compatible regexps to vim (i.e. to write a translator Perl 5-style to vim-style.)
In the mean time you can just use the likes of :perl and :perldo (see. :help perl for more info).