10

Background

I work at a research laboratory and use three different OS's daily. On the Windows and Mac machines I make use of Caffeine to keep those machines from enabling the screensaver while I work on a different machine (Linux doesn't have this problem). It's very annoying to have to log in again when I switch back.

Problem

When vim or gvim are in insert mode, the character <F15> sporadically appears in the document. I tracked it back to Caffeine after a bit of research. The website for Caffeine states that the software works by occasionally simulating a <F15> key press event:

Of all the key presses available, F15 is probably the least intrusive (I've never seen a PC keyboard with that key!), and least likely to interfere with your work.

So Caffeine is the obvious culprit. However, I still prefer to use my favorite text editor on all three machines, and don't intend to change that just to accommodate using Caffeine.

Question

Is there something I can put in my vimrc to make vim ignore <F15> key press events?


Edit For Clarity

I can't disable the screensaver timeout; it is set by the IT department for security purposes. So with the Caffeine work-around, in order to remain compliant, I have to manually lock my machines when I step away from my desk. That's not so bad; but unlocking them every few minutes is.

Also, I didn't write Caffeine, so I don't know why the developer chose to click <F15> once a minute. I probably would have done it differently, perhaps with a slight mouse motion or touchpad tap, as @Random832 suggested.

  • 4
    Why not just disable screensavers/timeout-to-lock on those machines? It'd be a much cleaner solution than to configure vim to work around Caffeine's strange behavior. Or at least make Caffeine simulate something like <Ctrl> instead of <F15>. – Ruslan May 20 '15 at 16:48
  • 1
    @Ruslan The point of using <F15> is that it very rarely means anything and is generally ignored; <Ctrl>, however, is meaningful, and when triggered at the wrong time could cause unintended behavior. – Kyle Strand May 20 '15 at 18:19
  • @Ruslan the OS is configured by the IT department to lock after a period of inactivity; running Caffeine allows me to bypass that, as long as I manually lock my machines when stepping away from my desk. Further, I don't have the source code for Caffeine, so I can't alter it. – Jonathan Landrum May 20 '15 at 21:40
  • Why doesn't it just simulate that event you get when you tap the touchpad when tapping isn't enabled, but it still focuses the window you're over - but over the current window so it doesn't do anything? – Random832 May 21 '15 at 4:01
  • @Random832 that's a good question; I didn't write the program, so I don't know the logic behind choosing <F15> other than what's posted on the site. – Jonathan Landrum May 21 '15 at 16:11
19

You can map a key to <nop> (short for "no operation") to make it "do nothing".

This should make Vim ignore the <F15> key in all modes:

:noremap <F15> <nop> 
:noremap! <F15> <nop>

This will probably fix your problem, but I haven't tested it in your specific situation, as I don't have various Windows/OSX machines with Caffeine installed standing by :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.