> The point of Vim's (vi's) regular expressions is to make them quicker > to type interactively, which is how most regular expressions are used. > For example, you're more likely to want to search for a literal ( than > to want grouping, so by default ( is a literal character and \( is a > metacharacter. On the other hand * rarely occurs in text, so * is a > metacharacter and \* is a literal asterisk. The idea is that in the > most common situations the bare character does what you want and the > backslashed character has the less common meaning. Speed of typing > takes precedence over consistency.
I'm not sure this stands up to scrutiny. Is searching for text containing literal plus signs really more common than wanting to search for one or more of a certain atom? Do people search for dollar signs so rarely that it is better for it to represent end of line by default? Are pipe characters searched for more often than alternatives?! Are braces and parentheses so common yet square brackets so rare? I think a better explanation might be backward compatibility. The story may go something like this: In the beginning, there was the simple regex, supporting just ., *, ^, $, but once scripts were written with just these, and therefore assuming other punctuation matched itself, the regex language could only be extended by escaping the new characters used or by breaking stuff, and people opted for the escapes. Newer designs, such as Perl, don't suffer from this restriction. A 'new' vi (which I personally would be quite a fan of--a rewrite that does away with the inconsistencies and oddities that are the result of compatibility issues and a sprawling codebase, with a well designed, consistent and powerful scripting language, consistent operator behaviour, etc., etc.) would not suffer from that restriction either, and although because, yes, an editor is different to a scripting language, I doubt the regex language would be the same as Perl, I don't think it would be the same as Vim either. Smiles, Ben. > Contrast this with Perl, where regular expressions are built into the > language. There you write regular expressions once and then refer back > to them every time you edit the code, so consistency of syntax is more > important than speed of typing. In Perl a bare character is literal > if it's a letter or digit and special if it's punctuation, while a > backslashed character is special if it's a letter or digit and literal > if it's punctuation. That works well for Perl, but a strategy that > makes sense for a programming language doesn't necessarily make sense > for an editor. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
