Modelines | Zed Code Editor Documentation

Modelines are special comments at the beginning or end of a file that configure editor settings for that specific file. Zed supports both Vim and Emacs modeline formats, allowing you to specify settings like tab size, indentation style, and file type directly within your files.

Configuration

Use the modeline_lines setting to control how many lines Zed searches for modelines:

{
  "modeline_lines": 5
}

Set to 0 to disable modeline parsing entirely.

Emacs

Zed has some compatibility support for Emacs file variables.

Example:

# -*- mode: python; tab-width: 4; indent-tabs-mode: nil; -*-

Supported Emacs Variables

Vim

Zed has some compatibility support for Vim modeline.

Example:

# vim: set ft=python ts=4 sw=4 et:

Supported Vim Options

Notes

  • The first kilobyte of a file is searched for modelines.
  • Emacs modelines take precedence over Vim modelines when both are present.
  • Modelines in the first few lines take precedence over those at the end of the file.