开发者

Function keys replacement for vim in a mac?

开发者 https://www.devze.com 2023-03-09 16:45 出处:网络
I would like to know which keys (or keystrokes) would you use to replace the function keys for command mapping. I\'m using vim in a mac开发者_开发百科book pro and the function keys are used for some s

I would like to know which keys (or keystrokes) would you use to replace the function keys for command mapping. I'm using vim in a mac开发者_开发百科book pro and the function keys are used for some system/desktop/multimedia commands as the first option while the regular function key is accessed through the Fn modifier. Still, some of the Fn+FX keys are already destined for other system functions so forget about them.

Here comes my mappings:

  • F1 (default: vim help)
  • F2 -
  • F3 :make<CR>
  • F4 :make run<CR>
  • F5 :make clean<CR>
  • F6 :make ctags<CR> (generates tags file)
  • F7 :cp<CR> (quickfix: display previous error)
  • F8 :cn<CR> (quickfix: display next error)
  • F9 :NERDTreeToggle<CR> (filesystem explorer)
  • F10 :TagbarToggle<CR> (browse source code tags)
  • F11 -
  • F12 -

The commands I am missing the most are those of F9 and F10.


Vim's help has a topic about this.

I generally opt for the last suggestion and use <Leader> as the prefix for my mappings since I know it doesn't conflict with any default keybindings and it can easily be changed if I decide I don't want to use \.


You can map any key (or key sequerce) you want to f9 or f10. Put something like this in your .vimrc:

:noremap gm <F9>

or maybe:

:noremap gm :NERDTreeToggle<Return>

If you map it to something you can use in insert mode too, I think you have to make a separate mapping for that:

:noremap <C-T> :NERDTreeToggle<Return>
:inoramap <C-T> <ESC>:NERDTreeToggle<Return>
:vnoramap <C-T> <ESC>:NERDTreeToggle<Return>

You can probably just map to <F9>, but I put it in the long way because I don't have the F9 mapping.

0

精彩评论

暂无评论...
验证码 换一张
取 消