Sunday, January 29, 2012

Re: [vim] Problem with `inoremap jj '

On Sun, 29 Jan 2012, Clark J. Wang wrote:

> On Monday, January 30, 2012 2:24:55 PM UTC+8, Markus Osterhoff wrote:
>>
>> * Clark J. Wang <dear...@gmail.com> [120130 07:01]:
>>> So I wonder if the `jj' mapping can be ignored when doing
>>> copy-n-paste and only work when I'm typing from a keyboard.
>> :set paste
>> do your paste
>> :set nopaste
>>
>
> I knew 'paste' can work that around.
>
> My idea is to introduce a new option, say 'mapwait' which is a number
> in milliseconds. For example, if 'mapwait' is set to 100 then two 'j'
> chars entered in less than 100ms will not be considered as the `jj'
> mapping.

Interesting. I was about to suggest setting 'timeoutlen' to 100. But,
that's the opposite of what you're looking for. (It will wait up to 100
milliseconds for the next keystroke.)

I like the idea of 'mapwait', because it seems like the false-positive
rate could be very low (problems w/ spotty internet?), but the
true-positives that it would catch would be pretty numerous. Maybe set
it much lower, though, around 10ms. I'm an okay typist (60 WPM
according to an online test¹), but testing it via some Perl², my minimum
time between keystrokes was around the 50ms mark.

On the other hand, probably a less error-prone approach would be to
provide (or fix?) support for bracketed paste mode³. It's been
available in XTerm for a long time, and it's also supported by
rxvt-unicode. Unsure of its support in derivatives of either. And it
was disabled by default for a long time (might still be?).

--
Best,
Ben

¹: http://patorjk.com/typing-speed-test/
²: perl -MTerm::ReadKey -MTime::HiRes=time -lwe 'my $stop = "="; print "Type $stop to exit"; ReadMode 4; END { ReadMode 0 } my @times; while (1) { next unless defined($k = ReadKey -1); push @times, time; last if $k eq $stop; } print for map { int(1000 * ($times[$_]-$times[$_-1])) } 1..$#times'
³: http://www.xfree86.org/current/ctlseqs.html#Bracketed%20Paste%20Mode

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

Post a Comment