Keystroke command

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Keystroke command

Gua Chung Lim-2
Hi all,

My question is a little hard to explain.
I know how to use :map to imitate keystrokes.
But I don't want to use :map every time.
Is there anyway to use : command to imitate keystrokes without :map?
For example gUw is the keystrokes to change the current word to uppercase.
Can I put gUw into the command like...

:%s/^foobar/gUw/g
to change any foobar at the beginning of the line to FOOBAR?
(I know this is a wrong example, I'm trying my hard time to explain. ;-p )

Thank you,

--
Gua Chung Lim
 
To live is to love.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Keystroke command

Gua Chung Lim-2
* Gua Chung Lim ([hidden email]) wrote:

> Hi all,
>
> My question is a little hard to explain.
> I know how to use :map to imitate keystrokes.
> But I don't want to use :map every time.
> Is there anyway to use : command to imitate keystrokes without :map?
> For example gUw is the keystrokes to change the current word to uppercase.
> Can I put gUw into the command like...
>
> :%s/^foobar/gUw/g
> to change any foobar at the beginning of the line to FOOBAR?
> (I know this is a wrong example, I'm trying my hard time to explain. ;-p )
I found it.
:g/^foobar/norm! gUw

--
Gua Chung Lim
 
To live is to love.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Keystroke command

Tim Chase
On 2018-01-18 22:41, Gua Chung Lim wrote:
> For example gUw is the keystrokes to change the
> > current word to uppercase. Can I put gUw into the command like...
> >
> > :%s/^foobar/gUw/g
> > to change any foobar at the beginning of the line to FOOBAR?
> > (I know this is a wrong example, I'm trying my hard time to
> > explain. ;-p )  
> I found it.
> :g/^foobar/norm! gUw

For this particular one (replacing a pattern with its uppercase
version), you can use

  :%s/^foobar/\U&

There's a lot of power in Vim's search-and-replace, so it's worth
reading up at

  :help sub-replace-special

and continuing on to read at

  :help :s%


-tim




--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Keystroke command

Gua Chung Lim-2
* Tim Chase ([hidden email]) wrote:
> On 2018-01-18 22:41, Gua Chung Lim wrote:
> > :g/^foobar/norm! gUw
>
> For this particular one (replacing a pattern with its uppercase
> version), you can use
>
>   :%s/^foobar/\U&
I know this command, but \U is not keystroke.
So it is irrelevant to my question.
For keystroke commands, you can do many other things else,
other than simply change the letter case.

> There's a lot of power in Vim's search-and-replace, so it's worth
> reading up at
>   :help sub-replace-special
> and continuing on to read at
>   :help :s%
Thank you very much. :-)

--
Gua Chung Lim
 
To live is to love.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.