On Tue, Nov 24, 2009 at 03:03:52PM EST, Charles Campbell wrote:
> 
> Chris Jones wrote:
> > I have this in my .vimrc:
> >
> > nmap <Space> i<Space><Esc>

[..]

> This map looks quite recursive; the i<Space> invokes the map again
> (recursively), and repeats ad infinitum.  Seems to me you want a
> no-remap; try

> nno <Space> i<Space><Esc>

> Haven't tested this, though, and I haven't finished reading all the
> other replies yet (so this may be a repeat!)

Yes, that's definitely what caused the initial problem with the
recursive insertion of spaces. Someone else recommended :nno and I did a
bit of reading on the subject. It hadn't occurred to me that having
<Space> in both halves of the remap would cause recursion :-\

What started this in the first place, is that a couple of months ago, I
decided to tidy up my .vimrc and among many other different things I
blissfully decided to change:

:nmap <Space> i <Esc>

to:

:nmap <Space> i<Space><Esc> 

This looked pretty harmless and I remember thinking that it would look
much 'cleaner' to have explicitly coded <Space> rather than a literal
space, because the literal space being by nature invisible, it could be
a space, a tab, or any other non-printable character.

I went back to the first version above just to make sure I understood
the whole thing, and verified via a test that the first :nmap version of
the mapping does not cause recursion. That's why it had worked without
problems for at least a year. 

Naturally, by the time I had finished tidying up my .vimrc and
eventually noticed the crazy animation sequence where hitting <Space> in
normal mode in the middle of a line caused all following text to start
running away rightwards at something like a hundred characters per
seconds, well, I had made so many changes in my .vimrc that I didn't
even remember having touched that mapping.

For the record, it's even worse when you are at the end of a file, and
there is nothing visible after the cursor because what happens is that
the cursor disappears.  So I had not clue what was happening since I
didn't see anything. Only that vim had become unresponsive. Purely by
accident, I found that hitting Ctrl-C would take me out of this funny
mode and that an undo appeared to clear up any changes to the buffer.
But I was still a quantum step away from suspecting what was going on.   

It just goes to show, that I should have taken it one step at time and
tested each individual change like a pro :-\

It's only after I changed the mapping to 

:nnoremap <Space> i<Space><Esc>             " some comment

that I ran into the second unrelated problem where the map command not
being immediately terminated by an <eol> - caused the cursor to jump
forward thirteen columns. 

I never imagined even trivial mappings could be that tricky and cause so
much grief!

Thank you for your comments, and thanks to all who helped me straighten
this out!

CJ

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

Reply via email to