12

I'm looking through some random code, and at the top of it, it says this:

# -*- mode: ruby -*-
# vi: set ft=ruby :

What does this mean?

I know it's a simple question, but I couldn't find it out online because a) I don't even know what language this code is written in, and b) I'm very new to bash and vi.

  • 1
    This question doesn't seem to have anything to do with bash. – Michał Politowski Jan 19 '14 at 8:43
12

Those lines are modelines which tell an editor (e.g. emacs or vi) to choose a specific editing mode for a file. An editing mode affects how editor e.g. higlights and indents contents of the file.

You can read more about modelines for emacs (which are called file-local variables) here and modelines for vim here.

| improve this answer | |
  • 1
    It's modeline not magical line. – romainl Jan 19 '14 at 9:06
  • Actually it's most often called magical modeline where I come from, just to distinguish it from modeline of emacs which is entirely different thing. – user260419 Jan 19 '14 at 11:09
  • 1
    Well, in Vim, it's called "modeline" and in Emacs it's called "file-local variables". – romainl Jan 19 '14 at 17:45
  • I suggest an edit then. – user260419 Jan 19 '14 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.