GitHub Atom:如何根据名称对某些文件应用特定的语法突出显示 [英] GitHub Atom: How to apply a particular syntax highlighting to some files based on name

查看:111
本文介绍了GitHub Atom:如何根据名称对某些文件应用特定的语法突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何配置 GitHub的Atom ,使其根据名称和/或扩展名自动为文件名设置特定的语法突出显示?

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

特别是我希望它为Cocoapods的Podfile s自动设置 Ruby语法高亮.

Specifically I want it to automatically set Ruby syntax highlightning to Cocoapods' Podfiles.

推荐答案

从Atom 1.0.8开始,使用核心功能,现在无需file-types包就可以实现此目的.为此,请打开config.cson文件,并添加如下部分:

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" ]

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

此处提供有关查找语言范围名称的指南: https://flight-manual.atom.io/using-atom/sections/basic-customization/#finding-a-languages-scope-name

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

<罢工> 现在,可以使用file-types 第三方软件包.我使用了以下语法:

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

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

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

应将其放置在config.cson文件中.

这是自述文件的摘录:

为语言指定其他文件类型.

Specify additional file types for languages.

在扩展名前删除点以使用扩展名匹配器.

Drop the dot before the extension to use extension matchers.

例如,您可以在config.cson中将.ex_em_eltext.xml关联 如下:

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

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

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

您也可以与正则表达式匹配.大多数JavaScript常规 表达式应该起作用;但是,系统会在以下位置找到一个点(.),一个脱字符号(^) 开头或美元($)来标识RegExp匹配器.

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.

例如,您可以将/.*_steps\.rb$/source.cucumber.steps关联 您的config.cson如下:

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

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

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

注意:扩展匹配器优先于RegExp匹配器.

NOTE: Extension Matchers take priority over RegExp Matchers.

这篇关于GitHub Atom:如何根据名称对某些文件应用特定的语法突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆