|
| ||||||||
BuffOptions.vim - Per-buffer options and mappingsIntroduction:Some of Vim's options are set per-buffer, but not all. This extension allows you to set any options and also mappings for a particular buffer or filetype. The idea is that you push options onto a stack (the old values are in fact what are pushed) with PushOption( ... ) and then restore the values with RestoreOptions(). An extension to the filetypes allow easy use of these macros for a specific filetype. The autocommands filetypeEnter and filetypeLeave have been added. Base Commands:
Example:
aug specialEdit
au!
au User sgmlEnter call PushOptions("keywordprg","/bin/htmlkey")
au User cEnter call PushOptions("breakat",". )&|", "complete",".,k/usr/dict,]", "nmap <c-enter>","<esc>o")
au User cEnter call PushOptions("amenu 10.100 Tools.Compile\\ C",":make<cr>" )
au User sgmlLeave,cLeave call RestoreOptions()
aug END
Per File mappingsThis is not really recommended, as it gives the document virus a foot in... so be warned. GetOptionsFromFile(comment) is a little trick to allow mappings defined for a particular file within the file. The lines recognized are of the form: <comment>vimexe: <arguments> where the arguments are the same as for PushOption. And Comment is passed as an argument. Despite the given example, I would recomend that you map a key to parse the options from a file initially. Note that the options are cached, so once read, you would have to unlet b:VIMEXE to be able to get it to reparse.
aug MyOpts
au!
au User vimEnter call GetOptionsFromFile('"')
au User vimLeave call RestoreOptions()
aug END
Mappings from filetype filesFor when you have a file that is used for the mappings for a particular filetype.All lines in the file except those starting with map and menu will get executed. Any maps/menus will get inserted into a BuffOption() for the specified filetype Commands:
Example:
let filename =$home.'/vim/txtsettings.vim'
call ReadFileTypeMap('txt',filename)
SO ~/vim/txtsettings.vim
Last Modified: 02 Aug 2000 15:47 by MGeddes | ||||||||