Pressing <CTRL-G> in visual mode causes vim to use 100% of the CPU.

64 views
Skip to first unread message

Dominique Pelle

unread,
Jan 25, 2008, 5:57:31 PM1/25/08
to vim_dev
Hi,

I've noticed that pressing <CTRL-G> while in visual mode,
causes vim to take 100% of the CPU.

I can interrupt it with <CTRL-C>.

Anybody else observing that?

Steps to reproduce bug:

1/ press v command to enter visual mode
2/ press <CTRL-G>
3/ observe that vim takes 100% of CPU

I'm using vim-7.1 (patches 1-241) on Linux x86 built
with "configure --with-features=huge".

-- Dominique

Ben Schmidt

unread,
Jan 25, 2008, 6:21:38 PM1/25/08
to vim...@googlegroups.com

> I've noticed that pressing <CTRL-G> while in visual mode,
> causes vim to take 100% of the CPU.
>
> I can interrupt it with <CTRL-C>.
>
> Anybody else observing that?

Not me. 7.1.203

Ben.

Send instant messages to your online friends http://au.messenger.yahoo.com

Dominique Pelle

unread,
Jan 25, 2008, 7:15:44 PM1/25/08
to vim...@googlegroups.com
On Jan 26, 2008 12:21 AM, Ben Schmidt <mail_ben...@yahoo.com.au> wrote:

> > I've noticed that pressing <CTRL-G> while in visual mode,
> > causes vim to take 100% of the CPU.
> >
> > I can interrupt it with <CTRL-C>.
> >
> > Anybody else observing that?
>
> Not me. 7.1.203
>
> Ben.


Ah, sorry, false alert. Investigating further, I found the root cause,
I had a silly recursive mapping in my ~/.vimrc:

map <c-g> 2<c-g>

I can't remember why I had such a senseless mapping. I suspect
it was meant to be:

map <c-g> g<c-g>

I never use <ctrl-g> and did not notice the problem until today.

I've removed the offending mapping from my ~/.vimrc and everything
is now OK.

Creating such a recursive mapping should perhaps give an error,
rather than causing infinite loops when triggering the mapping.

-- Dominique

Tony Mechelynck

unread,
Jan 25, 2008, 7:32:51 PM1/25/08
to vim...@googlegroups.com

Use ":noremap" instead and there will be no infinite loop.

Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
254. You wake up daily with your keyboard printed on your forehead.

ap

unread,
Jan 25, 2008, 8:09:05 PM1/25/08
to vim_dev


On Jan 26, 1:15 am, "Dominique Pelle" <dominique.pe...@gmail.com>
wrote:
(...)
>
> map <c-g> 2<c-g>
>
(...)
>
> Creating such a recursive mapping should perhaps give an error,
> rather than causing infinite loops when triggering the mapping.
>
> -- Dominique

What is more alarming then 100% cputime ? ;-)

-ap

Ben Schmidt

unread,
Jan 25, 2008, 8:16:12 PM1/25/08
to vim...@googlegroups.com
>> Creating such a recursive mapping should perhaps give an error,
>> rather than causing infinite loops when triggering the mapping.

The infinite loop is actually a feature, and documented.

:help recursive_mapping

Matt Wozniski

unread,
Jan 25, 2008, 11:21:35 PM1/25/08
to vim...@googlegroups.com
On Jan 25, 2008 7:15 PM, Dominique Pelle wrote:
>
> Ah, sorry, false alert. Investigating further, I found the root cause,
> I had a silly recursive mapping in my ~/.vimrc:
>
> map <c-g> 2<c-g>
>
> I can't remember why I had such a senseless mapping. I suspect
> it was meant to be:
>
> map <c-g> g<c-g>
>
> I never use <ctrl-g> and did not notice the problem until today.

No, it was meant to be
noremap <c-g> 2<c-g>

2<c-g> shows more information than <c-g>. It's briefly mentioned at
:help CTRL-g.

The output of <c-g>:
".vimrc" line 1 of 427 --0%-- col 1

The output of 1<c-g>:
"~/.vimrc" line 1 of 427 --0%-- col 1

The output of 2<c-g>:
buf 1: "~/.vimrc" line 1 of 427 --0%-- col 1

~Matt

Reply all
Reply to author
Forward
0 new messages