Accidentally pasting in Command Line mode

38 views
Skip to first unread message

Andy

unread,
Jul 3, 2010, 3:25:12 PM7/3/10
to vim_mac
Hi there,

I have one major annoyance with MacVim, which I'm surprised I can't
find anyone else mentioning. Specifically, on a semi-regular basis, I
copy a large amount of text from, e.g., a terminal session, switch to
vim, paste it, and - bang! I discover I was in command line mode and
as a result I am in for a long wait. For example I just did this with
235 lines of text, and had to wait around 10 minutes before vim was in
a usable state again. I can't interrupt with Ctrl-C nor Ctrl-Z. And
the rate of pasting seems to slow down exponentially, so you see
characters crawling along at a rate of about 10 a second.

I suppose I could remap Cmd-V on the command line, but I often want to
use it in that mode legitimately (with much less test).

Does anyone else see this behaviour? I only see it in the GUI version,
not in a terminal. Can anyone suggest a workaround? Or perhaps a way
of limiting the amount of text that can be copied to command-line
mode? Or a way of interrupting that I don't know? Any help much
appreciated. Thanks in advance,

Andy

björn

unread,
Jul 4, 2010, 6:58:22 AM7/4/10
to vim...@googlegroups.com
Hi,

On 3 July 2010 21:25, Andy wrote:
>
> I have one major annoyance with MacVim, which I'm surprised I can't
> find anyone else mentioning. Specifically, on a semi-regular basis, I
> copy a large amount of text from, e.g., a terminal session, switch to
> vim, paste it, and - bang! I discover I was in command line mode and
> as a result I am in for a long wait. For example I just did this with
> 235 lines of text, and had to wait around 10 minutes before vim was in
> a usable state again. I can't interrupt with Ctrl-C nor Ctrl-Z. And
> the rate of pasting seems to slow down exponentially, so you see
> characters crawling along at a rate of about 10 a second.

Ouch! I was not aware of this problem. Fortunately there is an easy
fix: use Cmd-. instead of Ctrl-C to interrupt.

Of course, Ctrl-C _should_ work but in some cases it does not because
it requires that Vim checks for incoming events. Sometimes when its
stuck in a long loop (like in your situation) it seems to "forget" to
do so. I will try to hunt down where it is stuck now and make it
check for incoming events and Ctrl-C will once more work.

It is because of situations such as this that I added Cmd-. as another
way of interrupting Vim (note that Cmd-. is the standard way to
interrupt Mac apps). It does not require Vim to check for incoming
events, instead it sends SIGINT to the Vim process so in general it is
a more effective way of halting Vim. (All of this is hidden under ":h
cmd-." in the MacVim help by the way.)

So, use Cmd-. for now. I'll try to make Ctrl-C work again when I get the time.

Björn

Andy Block

unread,
Jul 4, 2010, 7:13:38 AM7/4/10
to vim...@googlegroups.com
On Jul 4, 2010, at 12:58 PM, björn wrote:

> On 3 July 2010 21:25, Andy wrote:
>>
>> I have one major annoyance with MacVim, which I'm surprised I can't
>> find anyone else mentioning. Specifically, on a semi-regular basis, I
>> copy a large amount of text from, e.g., a terminal session, switch to
>> vim, paste it, and - bang! I discover I was in command line mode and
>> as a result I am in for a long wait.
>

> Ouch! I was not aware of this problem. Fortunately there is an easy
> fix: use Cmd-. instead of Ctrl-C to interrupt.

Hi Björn,

Thanks for you quick response, and suggested workaround. However, Cmd-. also does not appear to interrupt for me. Did you confirm that it worked for you? Would this behaviour depend on any configuration, or the setting of some option? Thanks again,

Andy

Andy Block

unread,
Jul 4, 2010, 7:26:26 AM7/4/10
to vim...@googlegroups.com
On Jul 4, 2010, at 12:58 PM, björn wrote:

> On 3 July 2010 21:25, Andy wrote:
>>
>> I have one major annoyance with MacVim, which I'm surprised I can't
>> find anyone else mentioning. Specifically, on a semi-regular basis, I
>> copy a large amount of text from, e.g., a terminal session, switch to
>> vim, paste it, and - bang! I discover I was in command line mode and
>> as a result I am in for a long wait.

> Ouch! I was not aware of this problem. Fortunately there is an easy
> fix: use Cmd-. instead of Ctrl-C to interrupt.

Hi again,

It just occurred to me that the reason this does not bite me in terminal vim is that pasting there results in the first pasted line being interpreted as a command, then the remaining lines get interpreted in normal mode, where they are swiftly interpreted and can easily be undone. In the GUI, however, the line separators get pasted as 'literal' ^M s on the command line, resulting in one huge command line. Furthermore, even if I take an equivalent amount os text but join all the lines onto a single line, and then cut and paste that onto a terminal command line, the paste is complete in a matter of less than a second (when using a buffer that takes over two minutes to paste into the GUI version). This suggests two other possible mitigating actions:

1. Make the behaviour for '^M' the same as the terminal version
2. Speed up the insertion of characters on the command line so they don't need interrupting :-)

In any case, thanks again for this and all your hard work on MacVim. It is a fantastic piece of software :-) . Regards,

Andy

björn

unread,
Jul 4, 2010, 9:46:03 AM7/4/10
to vim...@googlegroups.com
On 4 July 2010 13:13, Andy Block wrote:
> On Jul 4, 2010, at 12:58 PM, björn wrote:
>
>> On 3 July 2010 21:25, Andy wrote:
>>>
>>> I have one major annoyance with MacVim, which I'm surprised I can't
>>> find anyone else mentioning. Specifically, on a semi-regular basis, I
>>> copy a large amount of text from, e.g., a terminal session, switch to
>>> vim, paste it, and - bang! I discover I was in command line mode and
>>> as a result I am in for a long wait.
>>
>> Ouch!  I was not aware of this problem.  Fortunately there is an easy
>> fix: use Cmd-. instead of Ctrl-C to interrupt.
>
> Thanks for you quick response, and suggested workaround. However, Cmd-. also does not appear to interrupt for me. Did you confirm that it worked for you? Would this behaviour depend on any configuration, or the setting of some option? Thanks again,

Yes, I did confirm before posting. Which version of MacVim are you
using? You should be using a snapshot, or the 7.3a BETA [1] -- the
stable build is probably too old. No configuration option will affect
Cmd-. (it is hardwired).

Björn

[1] http://github.com/b4winckler/macvim/downloads

björn

unread,
Jul 4, 2010, 9:48:13 AM7/4/10
to vim...@googlegroups.com
On 4 July 2010 13:26, Andy Block wrote:
> On Jul 4, 2010, at 12:58 PM, björn wrote:
>
>> On 3 July 2010 21:25, Andy wrote:
>>>
>>> I have one major annoyance with MacVim, which I'm surprised I can't
>>> find anyone else mentioning. Specifically, on a semi-regular basis, I
>>> copy a large amount of text from, e.g., a terminal session, switch to
>>> vim, paste it, and - bang! I discover I was in command line mode and
>>> as a result I am in for a long wait.
>> Ouch!  I was not aware of this problem.  Fortunately there is an easy
>> fix: use Cmd-. instead of Ctrl-C to interrupt.
>
> It just occurred to me that the reason this does not bite me in terminal vim is that pasting there results in the first pasted line being interpreted as a command, then the remaining lines get interpreted in normal mode, where they are swiftly interpreted and can easily be undone. In the GUI, however, the line separators get pasted as 'literal' ^M s on the command line, resulting in one huge command line. Furthermore, even if I take an equivalent amount os text but join all the lines onto a single line, and then cut and paste that onto a terminal command line, the paste is complete in a matter of less than a second (when using a buffer that takes over two minutes to paste into the GUI version). This suggests two other possible mitigating actions:
>
> 1. Make the behaviour for '^M' the same as the terminal version
> 2. Speed up the insertion of characters on the command line so they don't need interrupting :-)

Thanks for the information -- I will try to take a look at why the GUI
is so slow.

> In any case, thanks again for this and all your hard work on MacVim. It is a fantastic piece of software :-) .

Thanks, I'm glad you like it. :-)

Björn

Andy Block

unread,
Jul 4, 2010, 1:40:30 PM7/4/10
to vim...@googlegroups.com

Ah - that'd be it then. I should have mentioned before that I am indeed using the last stable build (7.2). I'll have a go with something more recent then. Thanks again, regards,

Andy

Andy Block

unread,
Jul 4, 2010, 1:57:07 PM7/4/10
to vim...@googlegroups.com

On Jul 4, 2010, at 3:46 PM, björn wrote:

This should be my last posting on this matter - I just wanted to confirm that interrupting with Cmd-. on 7.3a BETA works fine for me. Furthermore, the paste seems to have sped up hugely since 7.2 anyway (possibly because, I notice, the screen is not refreshed after every character?). The paste that I previously reported as taking over 2 minutes now takes a much more reasonable 7 seconds. Consider me a happy customer! Thanks,

Andy

Carl Jacobsen

unread,
Jul 6, 2010, 2:56:12 PM7/6/10
to vim...@googlegroups.com
On 3 July 2010 21:25, Andy wrote:

> I have one major annoyance with MacVim, which I'm surprised I can't
> find anyone else mentioning. Specifically, on a semi-regular basis, I
> copy a large amount of text from, e.g., a terminal session, switch to
> vim, paste it, and - bang! I discover I was in command line mode and
> as a result I am in for a long wait.

(Sorry to come in at the end, just back from the long weekend.)

So, I paste text into MacVim all the time (with either Cmd-C/Cmd-V,
or drag and drop), and have always been pleased/grateful [THANKS BJ�RN!]
that it cheerfully inserted the text whether I was in command mode or
insert mode (after long painful experience with pasting into vi/vim
in the terminal and waiting while text was misinterpreted as a long
sequence of commands).

You say you're having this problem in command *line* mode -- if I'm
understanding right... is there some reason why you would go out of
your way to type ":" to get into command line mode, before switching
away from MacVim? Or am I misunderstanding?

Just curious,
Carl

Andy Block

unread,
Jul 6, 2010, 5:17:22 PM7/6/10
to vim...@googlegroups.com

On Jul 6, 2010, at 8:56 PM, Carl Jacobsen wrote:

> On 3 July 2010 21:25, Andy wrote:
>
>> I have one major annoyance with MacVim, which I'm surprised I can't find anyone else mentioning. Specifically, on a semi-regular basis, I copy a large amount of text from, e.g., a terminal session, switch to vim, paste it, and - bang! I discover I was in command line mode and as a result I am in for a long wait.
>
> (Sorry to come in at the end, just back from the long weekend.)
>

> So, I paste text into MacVim all the time (with either Cmd-C/Cmd-V, or drag and drop), and have always been pleased/grateful [THANKS BJÖRN!] that it cheerfully inserted the text whether I was in command mode or insert mode (after long painful experience with pasting into vi/vim in the terminal and waiting while text was misinterpreted as a long sequence of commands).


>
> You say you're having this problem in command *line* mode -- if I'm understanding right... is there some reason why you would go out of your way to type ":" to get into command line mode, before switching away from MacVim? Or am I misunderstanding?

Hi Carl,

Indeed, I am also most grateful that pasting in command or normal mode works with no problem. As a vi user in the (dim and distant) past, I know the pain that can result from pasting in 'normal mode' in vi (especially without multi-level undo). I certainly don't go out of my way to type ':' before pasting. It is more that I maybe went to vim, entered ':' with the intention of entering some command, then got interrupted, switch to skype to respond to something, went to firefox to look something up, then notice a mail that needs attention. Then I go to a terminal to copy some text I needed, before switching back to vim. Then I check which file I am pasting into, perhaps without carefully checking the bottom left for a ':', and... oops! It's not an everyday occurrence, but it has bitten me 4 or 5 times now. Hope that clarifies! Regards,

Andy

Reply all
Reply to author
Forward
0 new messages