Friday, May 27, 2011

Re: Keyboard left in a strange mode after ZZ

On Thu, May 26, 2011 at 5:00 PM, Ben Schmidt <mail_ben_schmidt@yahoo.com.au> wrote:
On 27/05/11 1:02 AM, Richard Guse wrote:
I'm using Vim 7.3 7/20/2010 under Windows 7.

I usually start gvim from the command-line but sometimes from Windows Explorer.

After I start, do my work then use "ZZ" to save/exit, it leaves the keyboard in a
strange state relating only to the window which was used to start gvim:

  before:  abc123
  after:  ABC!@#
  after (shift key):  ABC!@#
  after (caps lock):  abc!@#

There seem to be two ways to fix it...

  1. exit and restart the window
  2. in a bad window, re-start vim then type any command...even typing ":" and
exiting the window with the mouse works.  Just starting it then closing the window
doesn't fix it - something must be typed.

This doesn't happen with vim.
This doesn't happen with gvim if exited with :wq or :x.

I haven't noticed this behavior with any other application.

I've noticed several tips and messages relating to mapping caps lock to escape but
I don't map default keys.

I'm hoping someone here has seen this before as its driving me nuts.  It is
incredibly difficult to retrain myself to :wq or :x rather than ZZ.  I even tried
mapping ZZ to :x and it still happens.

Hmm. I guess it happens because Gvim does something keyboard-related
when it exits, but when you use ZZ, at that point the shift key is
depressed. To test the theory try doing

  :noremap ZZ 2gsZZ

That will put in a 2 second delay before exiting, which should be more
than enough time for you to release the shift key. See if that helps. If
it does, check you can reproduce the bad behaviour by continuting to
hold the shift key until after the 2 second delay passes and Vim exits.
 
That's it exactly!

I can now re-produce it not only by the above method but also by typing :q!<enter> but not lift the shift key when pressing enter.  Curiously, some capital letter must be pressed as :x<enter> while shift is pressed does not do it.  Explains why maping ZZ to :x doesn't fix the problem.

I reduced it to 1 second ":normap ZZ gsZZ" which appears to be plenty.  The delay is slightly annoying but much less annoying than funky caps lock.  ":noremap ZZ :sleep 300<CR>ZZ" works even better.  :)

Still can't re-produce it in any other application.  It must be unique to vim and my environment.

Thanks.

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