bash vi mode: What does # -*- mode: ruby -*- # vi: set ft=ruby : mean?

5,876

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.

Share:
5,876

Related videos on Youtube

michaelsnowden
Author by

michaelsnowden

Updated on September 18, 2022

Comments

  • michaelsnowden
    michaelsnowden over 1 year

    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.

    • Michał Politowski
      Michał Politowski over 10 years
      This question doesn't seem to have anything to do with bash.
  • romainl
    romainl over 10 years
    It's modeline not magical line.
  • Admin
    Admin over 10 years
    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.
  • romainl
    romainl over 10 years
    Well, in Vim, it's called "modeline" and in Emacs it's called "file-local variables".
  • Admin
    Admin over 10 years
    I suggest an edit then.