My vim setup( https://github.com/aaronjorbin/.vim ) contains set pastetoggle=<F2>
yet fn+F2 (when vim is running in terminal) causes vim to enter insert mode and output a Q
on it's own line (same behavior when I am already in insert mode). This is the same if I am working on my local machine or if I have sshed into another server.
In iterm2, nothing happens when I am in normal or visual mode. When I am in insert mode, <F2>
is inserted.
My config works perfectly well on my mac mini and linux netbook, but this is throwing me for a loop.
This is likely due to your TERM type being set to something other than xterm xterm-color or xterm-256color. I had mine set to linux for some reason I can't remember. This caused the function keys to send escape sequences instead of being interpreted as function key presses. ie- F2 was sending ^[OQ
instead of <F2>
.
If you need that terminal type you can change your .vimrc to use the key you want by pressing <ctrl-v><F2>
in place of typing <F2>
The easier fix is of course to just change your terminal type to something that allows vim to work without jumping through hoops.
You have set noesckeys
in your vimrc.
I've read a long time ago (no source, sorry) something about function keys being interpreted as <Esc>number
in some terminals (<Esc>9
for <F9>
).
If I'm correct and if I read :help noesckeys
correctly, set noesckeys
is blocking all function keys. Try commenting it out.
(Very late answer I know but someone else may find this useful)
I encountered the same problem (Vim7.4 on OSX10.9.5) and what worked for me was to set pastetoggle after setting nocompatible (nocp).
I found that on Macs the F2 key is mapped to "Turn Do Not Disturb On/Off". You can disable this setting under System Preferences -> Keyboard -> Shortcuts -> Mission Control. Uncheck the checkbox or pick another key. Picture below