GitHub Atom: How to apply a particular syntax highlighting to some files based on name

前端 未结 4 2123
广开言路
广开言路 2021-02-19 04:48

How can I configure GitHub\'s Atom to make it automatically set a particular syntax highlighting to filenames based on name and/or extensions?

Specific

4条回答
  •  轮回少年
    2021-02-19 05:22

    As of Atom 1.0.8 this is now possible without the file-types package, using a core feature. To achieve this, open the config.cson file, and add a section like the following:

    "*": # Other config core: customFileTypes: "source.ruby": [ "Podfile" ]

    There is guidance on finding the language scope name here: https://flight-manual.atom.io/using-atom/sections/basic-customization/#finding-a-languages-scope-name


    This is now possible with the file-types third-party package. I used the following syntax:

    "*": # Other config "file-types": "^Podfile$": "source.ruby"

    This should be placed in the config.cson file.

    Here's an excerpt from the readme:

    file-types package

    Specify additional file types for languages.

    Extension Matchers

    Drop the dot before the extension to use extension matchers.

    For example, you can associate .ex_em_el with text.xml in your config.cson as follows:

    'file-types': 'ex_em_el': 'text.xml'

    RegExp Matchers

    You can match with regular expressions, too. Most JavaScript regular expressions should work; but, the system looks for a dot (.), a caret (^) at the start, or a dollar ($) to identify RegExp matchers.

    For example, you can associate /.*_steps\.rb$/ with source.cucumber.steps in your config.cson as follows:

    'file-types': '_steps\\.rb$': 'source.cucumber.steps'

    NOTE: Extension Matchers take priority over RegExp Matchers.

提交回复
热议问题