Search code examples
programming-languagestext-editorsyntax-highlightingfile-extensionfile-type

Indicate programming language in a file without extension


When writing executable scripts, and declarative configuration files that use a common language (eg. Python), I often find it undesirable to add an extension to the file name. Many syntax-highlighting text editor (eg. Geany) are subsequently unable to automatically determine the filetype.

Is there any standard method for indicating to editors the type of source in the file?


Solution

  • Typically the shebang line is used as a fall-back.

    For example, a Ruby script without an extension would begin with:

    #!/usr/bin/env ruby