简体   繁体   中英

For the Vim editor, how do I map a function key in .vimrc on Mac OS X?

I'm trying to map f11 to a command within vim, with a line in .vimrc such as:

map <F11> :exe '!ctags -R --python-kinds=-i -f ./tags ' . shellescape(system('python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"'))<CR>

But if you hit F11 it just turns up the volume. Is it possible to remap keys that have OS-wide functions in OSX?

I don't want to remap any more commonly used key here because regenerating tags takes awhile.

You have two options that I know of:

1) Enable the regular use of the function keys, ie. f1 - f12 no longer executes the OSX specific command such as decrease volume. Instead you will have to hold the fn key press the f key. I have this set up on my computer and I've successfully mapped the function keys in Vim / MacVim. To do this go to System preferences --> Keyboard and check of the Use all F1, F2,...

2) Use fn + F11 to execute the command.

6 years later...

Check out https://github.com/Pyroh/Fluor/releases

It allows you to change the behavior of the function keys based on the app that is currently active.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM