Tuesday, February 16, 2016

Re: problem with a map

On 15/02/2016 09:11 a.m., Sam Burk wrote:
>> On 14/02/2016 05:16 p.m., Sam Burk wrote:
>>
>> Thanks for your answer. For example, on the following text (without the
>> dashes):
>>
>> ----------
>> aaa
>> 3.
>>
>> bbb
>> 4.
>>
>> ccc
>> 5.
>>
>> ddd
>> ----------
>>
>> I should get:
>>
>> ----------
>> aaa
>>
>> 3. bbb
>>
>> 4. ccc
>>
>> 5. ddd
>> ----------
>>
>> But I get:
>>
>> ----------
>> aaa
>>
>> 3.
>>
>> bbb
>>
>> 4.
>>
>> ccc
>>
>> 5. ddd
>> ----------
>>
>> As you see, it only works on the last line.
>
> That is odd. Try using nnoremap :g/^\d\+\.$/normal JJO<esc>. I tested it
> out in Vim with your example text, and it seems to work.

Thanks, it works, but I also noted that it also works if you replace
<esc> with <cr> as in:
nnoremap ,p :g/^\d\+\.$/normal JJO<cr>

The map I used, namely:
nnoremap ,p :g/^\d\+\.$/normal! O<Esc>jVjjJ<cr>

only works on the last line matching the pattern. It works on all lines
if I put <C-V> before <Esc> as in:
nnoremap ,p :g/^\d\+\.$/normal! O<C-V><Esc>jVjjJ<cr>

I wonder why do I need to use <C-V> whereas in your map it wasn't
necessary.

--
Cesar

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment