Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Case/lower/upper in vi

80 views
Skip to first unread message

JAW

unread,
Sep 19, 2012, 11:00:41 AM9/19/12
to

I have a file similar to the below with multiple entries of a similar nature.


I want to change /riskops/RISKOPS to /risktss/RISKTSS in one VM command. I can do it easily in two. Just basically the same string with one being lower case and the other being upper case as seen below.

From:

/u01/app/oracle/diag/rdbms/riskops/RISKOPS/cdump


to:

/u01/app/oracle/diag/rdbms/risktss/RISKTSS/cdump

Kenny McCormack

unread,
Sep 19, 2012, 11:25:01 AM9/19/12
to
In article <1f110714-6828-471b...@googlegroups.com>,
It is not at all clear what you're really talking about.

--
The motto of the GOP "base": You can't be a billionaire, but at least you
can vote like one.

Janis Papanagnou

unread,
Sep 19, 2012, 11:46:59 AM9/19/12
to
Am 19.09.2012 17:00, schrieb JAW:
>
> I have a file similar to the below with multiple entries of a
> similar nature.
>
>
> I want to change /riskops/RISKOPS to /risktss/RISKTSS in one VM
> command. I can do it easily in two. Just basically the same string
> with one being lower case and the other being upper case as seen
> below.

Not sure if that is what you want; vim:

:s/\(risk\)...\(.*\)\(RISK\).../\1tss\2\3TSS/

or

:s/riskops\(.*\)RISKOPS/risktss\1RISKTSS/

or clarify.

Janis

>
> From:
>
> /u01/app/oracle/diag/rdbms/riskops/RISKOPS/cdump
>
>
> to:
>
> /u01/app/oracle/diag/rdbms/risktss/RISKTSS/cdump
>

Ed Morton

unread,
Sep 19, 2012, 12:32:52 PM9/19/12
to
If you're asking how to change one word to another and keep the case of
the letters the same, e.g. so that some command "X" when run like this:

X/foo/bar/g

would change all occurrences of foo to bar and all occurrences of FOO to
BAR, there is no command like that.

Ed.


Posted using www.webuse.net

JAW

unread,
Sep 19, 2012, 12:34:43 PM9/19/12
to

If you're asking how to change one word to another and keep the case of
the letters the same, e.g. so that some command "X" when run like this:

X/foo/bar/g

would change all occurrences of foo to bar and all occurrences of FOO to
BAR, there is no command like that.

Ed.

Ed clarified what I am seeking to do .

Same text with different case I am attemping to do in one command.

Dan Espen

unread,
Sep 19, 2012, 2:43:49 PM9/19/12
to
This may not be helpful to you,
but emacs does case preserving change quite nicely.

If you change abc to def and start with:

abc ABC Abc

You get:

def DEF Def

--
Dan Espen

Ed Morton

unread,
Sep 20, 2012, 7:20:55 AM9/20/12
to
You'll need a vim plugin then. A quick google search shows you can use these

http://www.vim.org/scripts/script.php?script_id=6
http://vim.wikia.com/wiki/Script:6

or this:

https://github.com/tpope/vim-abolish

Apparently after installing them the "S" (for the second one or "%SC" for the
first) command will let you do:

:S/foo/bar/g

to replace 'Foo foo FOO' with 'Bar bar BAR'.

For more help I'd recommend you go to an editors NG or poke around the web pages
I mention above.

Regards,

Ed.

Ivan Shmakov

unread,
Sep 20, 2012, 8:10:04 AM9/20/12
to
>>>>> Ed Morton <morto...@gmail.com> writes:
>>>>> On 9/19/2012 11:34 AM, JAW wrote:

[...]

>> Same text with different case I am attemping to do in one command.

> You'll need a vim plugin then. A quick google search shows you can
> use these

> http://www.vim.org/scripts/script.php?script_id=6
> http://vim.wikia.com/wiki/Script:6

> or this:

> https://github.com/tpope/vim-abolish

> Apparently after installing them the "S" (for the second one or "%SC"
> for the first) command will let you do:

> :S/foo/bar/g

> to replace 'Foo foo FOO' with 'Bar bar BAR'.

> For more help I'd recommend you go to an editors NG

That's what cross-posting is for, BTW.

(... Setting Followup-To: to news:comp.editors just as well.)

> or poke around the web pages I mention above.

--
FSF associate member #7257

Janis Papanagnou

unread,
Sep 20, 2012, 11:43:51 AM9/20/12
to
Am 20.09.2012 13:20, schrieb Ed Morton:
[...]
> You'll need a vim plugin then. A quick google search shows you can use
[ links to plugins snipped ]
>
> Apparently after installing them the "S" (for the second one or "%SC"
> for the first) command will let you do:
>
> :S/foo/bar/g
>
> to replace 'Foo foo FOO' with 'Bar bar BAR'.

Curious; how would that plugin (or the respective emacs function) handle

:S/foo/bart/g

if applied on the quoted data ('Foo foo FOO')? - A literal small 't' in
all three parts ('Bart bart BARt'), or some magic like 'Bart bart BART'?

Janis

> [...]


Ed Morton

unread,
Sep 20, 2012, 12:26:34 PM9/20/12
to
From what I read on the web pages, it looks like the last one. I also saw an
example where they somehow do a translation on a mixed case word, but I can't
find that now and I can't be bothered to look for it again. At least one of
the macros I posted links to can also convert foo_bar to fooBar, etc. Google
(and maybe comp.editors) is your friend...

Ed.

Posted using www.webuse.net

Ben Bacarisse

unread,
Sep 20, 2012, 1:11:09 PM9/20/12
to
Janis Papanagnou <janis_pa...@hotmail.com> writes:
<snip>
> Curious; how would that plugin (or the respective emacs function) handle
>
> :S/foo/bart/g
>
> if applied on the quoted data ('Foo foo FOO')? - A literal small 't' in
> all three parts ('Bart bart BARt'), or some magic like 'Bart bart
> BART'?

Emacs does the magic one. The term suggests you think this option is a
little mysterious, but it seem like the natural option to me.

--
Ben.

Janis Papanagnou

unread,
Sep 20, 2012, 1:45:51 PM9/20/12
to
Not mysterious, but you can't tell whether that's the "Right Thing" to
assume be the only answer; I think it depends on the context. Example:
You have in a text some misspelled, or rather syntactically malformed,
words: "My set of dvc is as large as your set of DVC." and you, maybe,
want it to become: "My set of dvds is as large as your set of DVDs.",
then the plural 's' should not be capitalised. Maybe this ad hoc made
up case is rarer than the ones covered by the "magic" behaviour, but
possible anyway, and thus it depends. But maybe emacs' "magic" is so
advanced that it handles even that case. ;-)

Janis

Barry Margolin

unread,
Sep 20, 2012, 2:34:28 PM9/20/12
to
In article <k3fkn2$pd3$1...@news.m-online.net>,
These things are heuristics. By definition, a heuristic is intended to
handle the common case, but it shouldn't be expected to be perfect.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Dave Gibson

unread,
Sep 20, 2012, 5:34:22 PM9/20/12
to
Ed Morton <morto...@gmail.com> wrote:
> Janis Papanagnou <janis_pa...@hotmail.com> wrote:
>
>> Am 20.09.2012 13:20, schrieb Ed Morton:
>> [...]
>> > You'll need a vim plugin then. A quick google search shows you can use
>> [ links to plugins snipped ]
>> >
>> > Apparently after installing them the "S" (for the second one or "%SC"
>> > for the first) command will let you do:
>> >
>> > :S/foo/bar/g
>> >
>> > to replace 'Foo foo FOO' with 'Bar bar BAR'.
>>
>> Curious; how would that plugin (or the respective emacs function) handle
>>
>> :S/foo/bart/g
>>
>> if applied on the quoted data ('Foo foo FOO')? - A literal small 't' in
>> all three parts ('Bart bart BARt'), or some magic like 'Bart bart BART'?
>
> From what I read on the web pages, it looks like the last one. I also
> saw an example where they somehow do a translation on a mixed case
> word, but I can't find that now

<http://groups.google.com/group/comp.lang.awk/tree/browse_frm/month/2004-04/cf79de51a66671e1?rnum=31&_done=%2Fgroup%2Fcomp.lang.awk%2Fbrowse_frm%2Fmonth%2F2004-04%3F>

HARLAN! HARLAN!!! BECAUSE THAT WOULDN'T RESPECT LITERAL REGULAR
EXPRESSIONS. YESSSSSS!

> and I can't be bothered to look for it again.

:|

> At least one of the macros the macros I posted links to can also

Janis Papanagnou

unread,
Sep 21, 2012, 4:26:25 AM9/21/12
to
To be useful that feature (as every function) should be well defined.
My question was, how does it (emacs, vim plugin) behave in cases where
two sensible applications/interpretations/functions are possible. Even
any approach based on a heuristic evaluation what might be considered
more useful in most cases should be well defined for an editor operator.
My question was not about a "perfect solution", rather about the chosen
actual implementation.

Janis

>

0 new messages