Quantcast

Macro-keys

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Macro-keys

George Papanikolaou
Hi,

I was just wondering why the (more-easily typed) 'q' button is mapped by default to *record* a macro and the '@' character to actually "play" the macro back....

I think most users run macros way more times than record them.
How can I swap the functionality??

Thanks.

George Papanikolaou.

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Macro-keys

esquifit-2


On 25 Abr, 13:13, George Papanikolaou <[hidden email]> wrote:
> Hi,
>
> I was just wondering why the (more-easily typed) 'q' button is mapped by default to *record* a macro and the '@' character to actually "play" the macro back....
>
> I think most users run macros way more times than record them.
> How can I swap the functionality??

I guess this is justified by the fact that the potential damage of
accidentally typing q instead of @ is much lower as that of
accidentally typing @ instead of q. For one reason: q alerts you that
you are starting to record a macro and gives you the opportunity to
abort the action, while @ silently waits for the next letter to be
typed, which can be any, and it executes the associated macro (if
any), possibly without the user noticing it.

Speculations aside, a simple mapping like

nnoremap q @
nnoremap @ q

should do what you want. Unless I am too naive.

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Macro-keys

Ben Fritz
On Wednesday, April 25, 2012 7:58:09 AM UTC-5, esquifit wrote:
>
> Speculations aside, a simple mapping like
>
> nnoremap q @
> nnoremap @ q
>
> should do what you want. Unless I am too naive.

Sadly I don't expect that to work, but do report back if it does.

:help q says,

"The 'q' command is disabled while executing a register, and it doesn't work inside a mapping and :normal."

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Macro-keys

Benjamin R. Haskell-8
On Wed, 25 Apr 2012, Ben Fritz wrote:

> On Wednesday, April 25, 2012 7:58:09 AM UTC-5, esquifit wrote:
>>
>> Speculations aside, a simple mapping like
>>
>> nnoremap q @
>> nnoremap @ q
>>
>> should do what you want. Unless I am too naive.
>
> Sadly I don't expect that to work, but do report back if it does.
>
> :help q says,
>
> "The 'q' command is disabled while executing a register, and it
> doesn't work inside a mapping and :normal."

It works fine here.

As to the original question, for a long time I've used:

:nn Q @q

So 'qq' starts recording the macro named 'q', then 'Q' executes it.
Saves a lot of finger movement if you only usually deal with a single
macro at a time.

--
Best,
Ben H

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Macro-keys

John Little-4
In reply to this post by George Papanikolaou

> I was just wondering why the (more-easily typed) 'q' button is mapped by default to *record* a macro and the '@' character to actually "play" the macro back....

The reason is that this is vi compatible.  vi could play macros with @, but could not record them, one had to yank (or delete) into a register before playing the contents as a macro.  The "more-easily typed" q was one of the few keys not used by vi.  (The other letters were g, v and z, somewhat heavily used by vim.)

vi compatiblity is taken very seriously by vim.  I speculate that's partly because there's a vi spec in POSIX and vim enables Gnu/Linux to be POSIX, so to speak.

Regards, John

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Macro-keys

Ben Fritz
In reply to this post by Benjamin R. Haskell-8
On Wednesday, April 25, 2012 12:31:42 PM UTC-5, Benjamin R. Haskell wrote:
> >
> > :help q says,
> >
> > "The 'q' command is disabled while executing a register, and it
> > doesn't work inside a mapping and :normal."
>
> It works fine here.
>

I admit I never actually tried using q inside a mapping, I assumed the help text was correct. If q actually works inside a mapping, what does the help text actually mean?

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Macro-keys

Ümit Kablan
Hi,

26 Nisan 2012 17:32 tarihinde Ben Fritz <[hidden email]> yazdı:

> On Wednesday, April 25, 2012 12:31:42 PM UTC-5, Benjamin R. Haskell wrote:
>> >
>> > :help q says,
>> >
>> > "The 'q' command is disabled while executing a register, and it
>> > doesn't work inside a mapping and :normal."
>>
>> It works fine here.
>>
>
> I admit I never actually tried using q inside a mapping, I assumed the help text was correct. If q actually works inside a mapping, what does the help text actually mean?

I guess it might mean recursive macro is disabled. You cannot make a
(normal mode) q with the same meaning..

>
> --
> 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



--
Ümit

--
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
Loading...