Re: vim7: feature request - sub-replace-special extension
- View SourceDnia sobota 30 lipiec 2005 15:53, Tony Mechelynck napisał:
> ----- Original Message -----Doesn't work literal version of
> From: "Mikolaj Machowski" <mikmach@...>
> To: <vim-dev@...>
> Sent: Saturday, July 30, 2005 2:40 PM
> Subject: Re: vim7: feature request - sub-replace-special extension
> > Dnia sobota 30 lipiec 2005 02:06, Tony Mechelynck napisał:
> >> You can use Ctrl-V u 20AC (without the spaces) in a substitute, see
> >> ":help i_CTRL-V_digit" which is not only for insert mode but also on
> >> the command-line. You can also enter the Euro sign by means of a
> >> digraph, in this case Ctrl-K = e (without the spaces again; see "help
> >> digraph.txt"). So instead of \%u20ac you could hit ^Vu20ac (where ^V
> >> means "hit Ctrl-V") and see the euro sign appear in your substitute
> >> replacement text. (And if you use Ctrl-V to paste, then use Ctrl-Q
> >> instead.)
> > Doesn't work when you have make generic solution. In scripts
> > s/E/<c-v>u20ac/ (in all variants) doesn't work.
> > Tried it.
> Did you enter less-than, c, dash, v, greater-than or did you hit the
> Ctrl-V (or Ctrl-Q) key? The latter should work, but since it is used to
> insert a non-ASCII character into your script, you would need a
> "scriptencoding UTF-8" statement somewhere above it in the script (see
> :scriptencoding"), and you would need to have set 'encoding' and
> 'fileencoding' to UTF-8 when editing the script. _Then_ you should see
> (that's s, slash, E, slash, Euro) in your script, and it should work.
echo substitute('e', 'e', "\<c-v>u20ac", '')
You will see in command line ^Vu20ac.
>Bah. This version also don't work to full extend (of course works as
> >> You could also use an expression, as in \="\<Char-0x20AC>" but that
> >> would be more cumbersome than the ^V or ^K methods above.
> > Thanks - that is it. Looks really ugly but works. And as I need this
> > for script it doesn't really matter.
> > Bram - scrap feature wish but this tip could be added to
> > sub-replace-special/expression help. Like:
> > Expression can be used to insert character by its numerical value.
> > Example:
> > s/E/\="\<Char-0x20ac>"/g
advertised in docs, but...). Example:
echo substitute("asdf U+2211", "U+\([a-fA-F0-9]\)",
Doesn't work because \= resolves only first level of expression (replace
submatch with 2211) but will not insert Char.