Hi Tony :)

    Once more, Antoine came to the rescue :)) You're great, dude :)

 * A.J.Mechelynck <[EMAIL PROTECTED]> dixit:
> DervishD wrote:
> >    In Perl I would store the complex pattern in some scalar, but I
> >don't know how to do it in VimL. Probably it can be done with "let"
> >and "eval", but it won't work for syntax highlighting, AFAIC.
> 
> In Vim you can store the pattern in a variable or in a register. At
> the keyboard, you can recall a register in Command-line or
> Insert/Replace modes by hitting Ctrl-R followed by the register name
> (e.g. ^R/ to recall the latest search pattern, ^Rw to recall register
> "w, ^R= followed by an expression then <Enter> to evaluate that
> expression, etc.)

    Yes, I knew this, but I thought that patterns were special in the
sense that they couldn't be stored in a register (well, really I thought
that only buffer text could be stored in a register).
 
> When interacting with Vim at the keyboard, you can also recall the
> previously used pattern from search history (using <Up> and <Down>
> after hitting / or ? ) and modify it on the command-line before
> hitting <Enter> (or <Esc> to abord) on the modified pattern.

    Cool!

> Or you can use ":let" to set @/ (the search register) and immediately
> do searches based on the new value. For instance, to repeat the latest
> search but as a self-standing word:
> 
>       :let @/ = '\<' . @/ . '\>'

    And I just forgot completely about the search register. My fault :(

> >    Moreover, if I'm writing a syntax file and have a lot of syntax
> >items that contains the same complex pattern preceded and followed by
> >a character (this is only an example), that's difficult to maintain
> >because each time I have to change the complex pattern I have to
> >change it everywhere. Please note that this cannot be fixed modifying
> >the pattern adding an whatever\? atom at the front and end of it,
> >because the "whatever" MUST be present at BOTH ends.
> 
> Any ex-command (including the ":syntax" command) can be constructed as
> a string expression, argument of the ":exe" command.

    Again, I thought that "syntax" could be used in "eval" but not with
"exe". I definitely must study the VimL syntax in the structural level
as shown in ":help expression-syntax" and think of any ex-command as an
ex-command and not as "syntax command", "text manipulation commands",
etc. Being vim an editor and not a programming language, I find
sometimes difficult not to "categorize" its capabilities. I just tend to
forget that VimL is a real programming language.

    Tony, again you've not only solved my doubt, but gave me an
important lesson about VimL. I owe you yet another one. I just hope
someday I will be able to return at least part of your kindness with me.

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
It's my PC and I'll cry if I want to... RAmen!

Reply via email to