Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

macos

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.

like image 509
user1022489 Avatar asked Oct 31 '11 18:10

user1022489


People also ask

How do I access .vimrc on Mac?

The path used by macOS's default vim install is /usr/share/vim/vimrc .

What is meta key in Mac?

What is the Meta Key ? The Meta Key (denoted as M or Meta ) is a modifier key which mean it temporarily modify the normal action of another key when pressed together. Common modifier keys are shift , alt , or control .

How do I enter insert mode in vi Mac?

vi mode has two submodes: insert mode and command mode. The default mode is insert. You can toggle between the modes by pressing Esc; alternatively, in command mode, typing a (append) or i (insert) will return you to insert mode.


1 Answers

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.

like image 77
GWW Avatar answered Sep 29 '22 05:09

GWW