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.


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.


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, 2015 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. May 20, 2015 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. May 20, 2015 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, 2015 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. May 21, 2015 at 16:11

2 Answers 2


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

  • It looks like that did it! Thank you for your help. May 20, 2015 at 14:50
  • 1
    It should be noted that presumably dead keys like <f15> are often used when Mapping fast keycodes in terminal Vim. Example of a plugin that does such a thing is rsi.vim. May 20, 2015 at 17:54
  • I've tried the following to keep Vim and Caffeine working together while Caffeine is active. None of these work. My caffeine is sending the F15 key, which is ^[[28~ noremap <F15> <nop> noremap! <F15> <nop> noremap <^[[28~> <nop> noremap! <^[[28~> <nop> nnoremap <F15> <nop> nnoremap <^[[28~> <nop> any ideas?
    – rem45acp
    Aug 17, 2020 at 16:43
  • 2
    You can try binding the "raw key code" as noremap <Esc>[28~ <nop> @rem45acp; that ^[ is the escape character, and you need to either use <Esc> or type a literal escape character (by pressing <C-v> and then the escape key; but just using <Esc> is easier). You also don't use <..> for raw key codes like that. Aug 18, 2020 at 3:53
  • @MartinTournoij I can confirm this works! Thank you.
    – rem45acp
    Oct 2, 2020 at 20:18

The other answer (and suggestions in the comments) didn't work for me, I opted for switching to MouseJiggler instead of Caffeine and the F15 problem is no more!


(I am not the author or anything, I honestly just looked around for something else and found that this really solved my problem well)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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