Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combined vim modeline + emacs local-variables line on a single line

Tags:

vim

emacs

Is it possible to have a single line in a file that acts as both a vim modeline and an emacs local variables line? If so, what would the syntax look like?

I realize that I can do it with two lines: by putting the emacs local-variable line as the 1st line of the file, and the vim modeline as the 2nd line (or 3rd, 4th, or 5th, if the modelines is unchanged from its default value); for example, for the case of an HTML file, like this:

<!-- -*- mode: Text; fill-column: 100 -*- -->
<!-- vim: set textwidth=100 : -->

But I’m wondering if I can put both on the same single line and still have vim and emacs parse them as expected—and if so, what the syntax would be.

like image 476
sideshowbarker Avatar asked Sep 04 '15 17:09

sideshowbarker


1 Answers

Yes, it’s possible; you can do something like this:

<!-- -*- mode: Text; fill-column: 100 -*- vim: set textwidth=100 :-->

…and then if you open that file in emacs and check the value of fill-column, you’ll see that it's been set to 100 as expected; and open it in vim and check the value of textwidth and you’ll see that it’s been set to 100 as expected.

like image 85
sideshowbarker Avatar answered Sep 18 '22 11:09

sideshowbarker