On 16/04/09 20:18, Rogers, Brian A. wrote:
> I’m trying to write a quick s+r to replace single line “multi-line
> style” comments with single-line style comments.
>
> For some reason, it won’t match when I use paren’s to store match fragments.
>
> Below is what I’m using
>
> :%s#/\*(.*)\*/#//\1#g
>
> This winds up matching nothing in my file, where if I do a search with
> the same pattern without the paren’s everything’s great.
>
> Also, this string works (or at least matches) with the following perl
>
> perl –pi –e “s/\/\*(.*)\*\//\/\/\1/g” filename.cpp
>
> Any ideas? Is there something different about these search “registers”
> in vim versus the rest of the unix regexp world?
>
> Any help would be greatly appreciated.
>
> (And yes I can do this in two passes, but I’m looking for the regexp
> solution so I know how to use this syntax in Vim)
>
> Thanks!
Others have given the answer, but the fact is, Vim regexps are not
identical with the regexps used by other unix programs (and I'm not sure
they all use the same regexps either). In addition, Vim regexps come in
four degrees of "magicness" (from "very magic" to "very nomagic")
differing in what must be backslash-escaped to mean what; though the
simply "magic" setting is the default, and therefore usually regarded as
standard.
See
:help pattern.txt
and in particular
:help pattern-overview
:help /magic
:help perl-patterns
(the latter _compares_ the patterns of Perl and Vim).
Best regards,
Tony.
--
Proposed Additions to the PDP-11 Instruction Set:
PI Punch Invalid
POPI Punch Operator Immediately
PVLC Punch Variable Length Card
RASC Read And Shred Card
RPM Read Programmers Mind
RSSC reduce speed, step carefully (for improved accuracy)
RTAB Rewind tape and break
RWDSK rewind disk
RWOC Read Writing On Card
SCRBL scribble to disk - faster than a write
SLC Search for Lost Chord
SPSW Scramble Program Status Word
SRSD Seek Record and Scar Disk
STROM Store in Read Only Memory
TDB Transfer and Drop Bit
WBT Water Binary Tree
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---