Counts and a recursive mapping that shouldn't be

classic Classic list List threaded Threaded
3 messages Options
enk
Reply | Threaded
Open this post in threaded view
|

Counts and a recursive mapping that shouldn't be

enk

Hi people!

I'm programming some x86 assembly, where all my stack offsets are 4
bytes. Once in a while, I'll want to change e.g.

movl 4(%ebp), %eax
into
movl 8(%ebp), %eax

Now CTRL-A four times or 4CTRL-A will do that. But being bent on
optimization I wanted CTRL-A and CTRL-X to move in steps of four.
First, I tried:

noremap <c-a> 4<c-a>

which works fine until I want to use it with a count, e.g. 2CTRL-A
works like 24 increments instead of 8 and 3CTRL-A as 34 instead of 12
and so on. Now, guided by the vim manual, I did:

noremap <c-a> @='4<c-a>'<cr>

This sends vim into recursion that is not stopped by maxmapdepth!

Any ideas?


Regards,
Erik

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Counts and a recursive mapping that shouldn't be

Yegappan Lakshmanan

Hi,

On Thu, May 7, 2009 at 2:09 PM, Erik Wognsen <[hidden email]> wrote:

>
> Hi people!
>
> I'm programming some x86 assembly, where all my stack offsets are 4
> bytes. Once in a while, I'll want to change e.g.
>
> movl 4(%ebp), %eax
> into
> movl 8(%ebp), %eax
>
> Now CTRL-A four times or 4CTRL-A will do that. But being bent on
> optimization I wanted CTRL-A and CTRL-X to move in steps of four.
> First, I tried:
>
> noremap <c-a> 4<c-a>
>
> which works fine until I want to use it with a count, e.g. 2CTRL-A
> works like 24 increments instead of 8 and 3CTRL-A as 34 instead of 12
> and so on. Now, guided by the vim manual, I did:
>
> noremap <c-a> @='4<c-a>'<cr>
>
> This sends vim into recursion that is not stopped by maxmapdepth!
>
> Any ideas?
>

You can try using something along the lines of the following command:

nnoremap <c-a> :<c-u>exe 'norm! ' . <c-r>=v:count1*4<cr> . '<c-a>'<CR>

- Yegappan

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

enk
Reply | Threaded
Open this post in threaded view
|

Re: Counts and a recursive mapping that shouldn't be

enk

On Fri, May 8, 2009 at 01:28, Yegappan Lakshmanan <[hidden email]> wrote:

>
> Hi,
>
> On Thu, May 7, 2009 at 2:09 PM, Erik Wognsen <[hidden email]> wrote:
>>
>> Hi people!
>>
>> I'm programming some x86 assembly, where all my stack offsets are 4
>> bytes. Once in a while, I'll want to change e.g.
>>
>> movl 4(%ebp), %eax
>> into
>> movl 8(%ebp), %eax
>>
>> Now CTRL-A four times or 4CTRL-A will do that. But being bent on
>> optimization I wanted CTRL-A and CTRL-X to move in steps of four.
>> First, I tried:
>>
>> noremap <c-a> 4<c-a>
>>
>> which works fine until I want to use it with a count, e.g. 2CTRL-A
>> works like 24 increments instead of 8 and 3CTRL-A as 34 instead of 12
>> and so on. Now, guided by the vim manual, I did:
>>
>> noremap <c-a> @='4<c-a>'<cr>
>>
>> This sends vim into recursion that is not stopped by maxmapdepth!
>>
>> Any ideas?
>>
>
> You can try using something along the lines of the following command:
>
> nnoremap <c-a> :<c-u>exe 'norm! ' . <c-r>=v:count1*4<cr> . '<c-a>'<CR>

Thanks! Works nicely!

/Erik

>
> - Yegappan
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---