Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Modelines

A modeline is a comment in a file that sets how that file is edited: its indentation, its wrap column, whether it ends with a newline. Vix™ reads Vim modelines and Emacs file variables, so files that already carry them for Vim or Emacs users work the same way in Vix.

# vim: set et sw=4 tw=79:
/* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8 -*- */

A modeline wins over the file’s .editorconfig, which wins over your settings.

What Vix reads

SettingVimEmacs
Indent with a tab, or with spacesnoet / noexpandtab, et / expandtabindent-tabs-mode: t / nil
Indent sizesw=N / shiftwidth=Nc-basic-offset: N, python-indent-offset: N, js-indent-level: N, …
Tab widthts=N / tabstop=Ntab-width: N
Wrap column for Wrap Texttw=N / textwidth=Nfill-column: N
Soft wrapwrap, nowraptruncate-lines: nil / t
End the file with a newline on saveeol, fixeol, and noeol, nofixeolrequire-final-newline: t / nil

Everything else in a modeline is ignored. That is deliberate: a file can set its own layout, but it cannot make Vix run anything or change any other setting. A file type (ft=, mode:) is ignored too; Vix picks the language from the file name.

Where Vix looks

  • Vim modelines in the first and last five lines of the file: vim:, vi: or ex: at the start of a line or after a space. Both forms work: vim: set ts=4 sw=4: and vim: ts=4 sw=4.

  • An Emacs -*- … -*- line, as the first line of the file, or the second after a #! line.

  • An Emacs Local Variables: block near the end of the file:

    # Local Variables:
    # fill-column: 72
    # End:
    

When a file has both, the Emacs settings win. Among Vim modelines, as in Vim, a later one wins.

Turning it off

The modeline_lines setting is how many lines at each end of a file Vix searches. 0 turns modelines off:

modeline_lines = 0

Vix™ and Vix IDE™ are trademarks.