Monday, August 23, 2010

Preventing accidental command-line pastes from destroying the universe

Hi all,
Note that this is *not* a vim 7.3-related issue -- I'm still running
7.2. I'm using the ubuntu 10.04 `vim-gnome` package.

I've noticed that pasting into the command line from a register uses
a conspicuous amount of resources, both in terms of processing time
and memory. This can easily clog up the operation of a machine, and
can happen quite easily if you just hit the wrong key by accident. It
happens very slowly, taking up to a second just to paste in one screen
row's worth of text.

Today I accidentally pasted the entire jQuery source code into the
vim command line by pressing `<C-R>+`. `^C` didn't seem to work to
cancel this operation, although I pressed it pretty early in, after
there were only a few rows of pasted text. I thought maybe just
letting it go might be okay, and just used cpulimit to prevent it from
hogging lots of CPU while I worked on something else. After a few
minutes that vim process had consumed at least another couple of
hundred megs of memory, at which point I killed it from another
process. I was able to kill it with a normal kill signal (i.e. not
`kill -9`), at which point it exited gracefully, notifying me that it
had saved files (though not saved a session).

Presumably this is a complicated issue which can't easily be
rectified (unless it is fixed in vim 7.3?). Is there a workaround of
some variety? Even just placing a fixed limit on the length of a
command line entry, at a few hundred characters or so, would prevent
these sort of catastrophes.

Alternatively, perhaps there is a way to get vim to save a session
file when it exits due to an interrupt signal? Not perfect, since
there are a few items not saved in a session file, but for a quick fix
it would be helpful.

Thanks
-Ted

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

No comments: