sponsor Vim development Vim logo Vim Book Ad

let-modeline.vim : Extends the modeline feature to the assignment of variables

 script karma  Rating 24/9, Downloaded by 2430  Comments, bugs, improvements  Vim wiki

created by
Luc Hermitte
 
script type
utility
 
description
The file defines the function FirstModeLine().

Its purpose is very simple. It consists in extending VIM modelines (:h modeline for more info) to custom variables -- these variables can then be used to customize other VIM scripts.

For instance, if your file foo.vim has as one of its first or last lines:
   " VIM: let b:toto="foo" g:tata=4 g:egal="t=y".&tw $CPPFLAG='-I../../libs'
Then, once the buffer is (re)loaded, one buffer relative variable (b:toto) and two global variables (g:tata and g:egal) are defined to the value specified after the equal sign.

Personnaly, I use it in conjunction with tex-tools.vim in order to know the name of the main file of the current document and then call latex on the main file and not on the currently edited file -- I use intensively \\include{} and \\includeonly{}.

Regarding the security issue, the script forbids calls to functions in the right hand operand -- it prevents from trojans. Nevertheless, it is possible to call functions thanks to a buffer relative callback feature. This time, only one function could be called. Trojans are still possible if the callback functions (that you have accepted in your configuration) want it to be possible -- like calling a function named after the value passed in parameter...
The callback feature has been implemented to be used in conjunction with ftplugins ; cf. tex-maps.vim and tex-tools.vim on my Web site:
    http://hermitte.free.fr/vim/tex.php

Note: The version 1.5 is the last one which can be used with Vim 5.x.
 
install details
Drop this file into your {rtp}/plugin/ directory. let-modeline is also shipped with lh-misc.

In any case prefer to install the version from https://github.com/LucHermitte/lh-misc/blob/master/plugin/let-modeline.vim
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
let-modeline.vim 1.9 2015-03-21 6.0 Luc Hermitte The latest version.
ip used for rating: 18.217.144.32

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 the maillist. Help Bram help Uganda.
   
Vim at Github