[oclug] Vim Rulez (was Programming Wars - Final Results)
Strosberg, Bill
bill.strosberg at rcpsc.edu
Thu Apr 19 09:48:02 EDT 2001
All:
PHP also incorporates regexp, including a Perl regexp mode. This made my
transition from Perl-based CGI/Perl DBI to PHP much more palatable. I use
regular expressions ... well ... regularly, and did not want to consider
life without them. Once you get used to describing things you want to do in
regular expressions, there is a elegant lexical economy that can not be
beat.
In vim, :% s/<.\{-}>//g will strip out all "<>" framed tags in a document,
leaving the content undisturbed (s/<.*>?//g in Perl,
preg_replace("<.*>?","",$exp) in PHP). Fifteen keystrokes to do something
next to impossible in most "editing" environments.
Yes, it looks like someone hit the top row if their keyboard with their
forehead while depressing the shift key, but I personally think that
learning regular expressions are more important than what
<controversy>/[editor|scripting language|distribution|upgrade tool|mail
client]/</controversy> is used or preferred.
--
Bill Strosberg
> There is unfortunately no regexp standard, but Perl tends
> to set it in a
> de facto manner. Yes, the ^ means "beginning of the line".
> Both Tcl and Python
> have incorporated Perl's regexps. Ex has basic support, about
> the same as
> grep. egrep has extended support (or grep -E for that
> matter). Awk and Sed's
> support is pretty good. Emacs has pretty decent support for
> regexp searches,
> but I prefer Vi in that it uses regexps all the time. In
> Emacs there are two
> different search modes.
More information about the OCLUG
mailing list