I recently asked a question in which I learned that it is not possible to pass anything except parameters to :set
in vim modelines. I understand the security concerns, but I'm wondering if there isn't another way around this. A recent question on SO about setting large batches of parameters to comply with a coding standard got me to thinking—would it be possible to define a "group" of things in my rc file that can be turned on or off from the modeline?
Excuse the pseudo code, but is there a way to create a function that is triggered from a set parameter?
set_function! codestyle()
if &1 == 'psr-2'
set ts=4
set sw=4
endfi
if &1 == 'drupal7'
set ts=2
set sw=2
iab D8 Drupal 8
endif
endset_function
This could then be triggered by a modeline such as
# vim: codestyle=psr-2
This would be in some ways be similar to file type matching, but allow manual overrides. It would also setting up the environment in other pre-defined ways, avoiding the security issues of having a file run other arbitrary commands in vim but allowing a more customized environment. Is there a way to do this?
set
; AFAIK, this is not possible in Vim ... – Martin Tournoij Mar 17 '15 at 12:31