Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are only some modeline settings being applied in Vim?

I'm editing python files and I have a modeline in one of them as follows:

# vim: set foldmarker={{{,}}} foldlevel=0  foldmethod=marker

When I open the file, foldmethod is still set to expr, but the other two settings in the modeline have been successfully applied, and set modeline? reveals that modeline is indeed set.

I suspect this is happening because a plugin is overriding the setting after the modeline is applied, but how can I check if that's the case?

like image 774
Will Avatar asked Mar 21 '23 02:03

Will


1 Answers

Actually, your modeline syntax is incorrect. You are setting foldmarker and foldlevel to the default values, so that's probably why it looks like those settings are being applied. Your modeline should be

# vim: set foldmarker={{{,}}} foldlevel=0 foldmethod=marker :

Note the : at the end of the line, it is required.

There is another syntax for modelines that doesn't require the closing colon but it also cannot have a leading set:

# vim: foldmarker={{{,}}} foldlevel=0 foldmethod=marker

Either one will work for you. I tend to use the first syntax because the second cannot be used in languages where you need some text at the end of the line to close the comment.

like image 147
Geoff Reedy Avatar answered Mar 31 '23 12:03

Geoff Reedy