sponsor Vim development Vim logo Vim Book Ad

intermediate Tip #214: Current buffer based menus

 tip karma   Rating 2/2, Viewed by 829 

created:   February 14, 2002 3:45      complexity:   intermediate
author:   Tomas Zellerin      as of Vim:   6.0

If you have different menus for different filetypes, and you want to have only the menu relevant to current buffer displayed, you can use this approach:

in .vimrc:
au BufEnter * if exists('b:BuffEnter')|exec b:BuffEnter|endif
au BufLeave * if exists('b:BuffEnter')|exec b:BuffLeave|endif

In appropriate ftplugin/?.vim, there are assigned commands to create or destroy the menus - here typed in directly, may be of course call to a menu-generating function or whatever.

let b:BuffEnter='amenu C.added ...'
let b:BuffLeave='unmenu! C|unmenu C'

 rate this tip  Life Changing Helpful Unfulfilling 

<<delet all lines containt TXT | Edit configuration files for a filetype >>

Additional Notes

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo