Supports modeline


In Vim, we can custom modeline for any file types, automatically setting options.

In Vim:

/* vim: ft=javascript: */

In Atom:

/* atom: ft=javascript */


I’m of mixed feelings on this one. Personally, I think this is a misfeature … it’s like putting an @author tag on a chunk of code. It is conflating data with metadata. On the other hand, I suppose some people’s workflow depends on it … so supporting it might be a good thing.

Then again, I think that putting the program’s name in the comment is silly. If the metadata is useful, then it is useful for all programs, not just Vim or Atom. I’d recommend something more along the lines of the # encoding system. So that it can look like this:

# encoding: utf-8
# syntax: ruby

Or to extend the above example:

/* encoding: utf-8 */
/* syntax: javascript */

Oh … and is this feature really called “modeline”? Because coming from Emacs, I was thinking something completely different.


I agree with you. Not just Vim, Atom, or others.
Just likes editorconfig, Front-matter.
You can define a protocol for the metadata, for all programs.
The modeline is a temporary name.
The above example is cool!


Oh … also if this were a thing, I’d expect Atom to be able to infer syntax from a shebang line too:

#! /usr/bin/env ruby
# encoding: utf-8
# Does not need a "syntax:" line because of the shebang


I believe that there is already a plugin with at least partial editorconfig support.

edit: correcting links


Do you think we’ll get grammar detection via shebang out of this thread? Should I file a separate feature request?

Update: nevermind, I see grammars already support this. Yay.


GitHub currently allows you to insert a comment as follows to allow proper color coding on the site…

# -*- mode: yaml -*-

This is great in case you want to use a something like YAML for config but do not want to use .yaml or .yml as your extension. It would be cool if the results of changing the type with ctrl + shift + l were applied if this comment was in place.


See this other topic where it is mentioned that there is already a package for this:

These two topics duplicate each other. Even though this topic is older, I feel like the newer one is more complete … so I’m going to select the newer one as the topic that will remain open.

We like to unify similar discussions under one topic so that people don’t have to read a bunch of different threads to get the whole story. Closing this topic as duplicate.