atom-editor - 键绑定(bind)的原子数据语法

标签 atom-editor

有人可以完整解释 Atom 的数据语法属性(用于键绑定(bind)选择器)的语法吗?

例如,有什么区别

[data-grammar='source example']

[data-grammar~='source example']

另外,如何指定多种语法?例如,您如何指定键绑定(bind)应限制为 html 或 xml 格式?

如果某处已经存在关于此的文档,我还没有找到它,但希望能指出它。

最佳答案

简单示例:

keymap.cson:

"atom-text-editor[data-grammar='text tex latex']":
  'f5':'latex:build'

语法信息和文档

我首先查看 file-types 包裹。 sourcetext对语言进行分类 - source处理开发语言,而 text处理文档/日志格式。 您可以通过阅读飞行手册来添加和自定义语言识别。我在下面链接了一些对此有帮助的特定部分。

Flight Manual | Basic Customization:

Language Recognition

Language Specific Settings

[data-grammar] 合作:

给出的小文档列在“深度键盘映射”部分下。

Flight Manual | Keymaps in Depth

Selectors and Custom Packages.

这也描述了not([...])下面使用的功能以及如何操作各种规则。

虽然在上面,语法是以点格式列出的,即source.c ,在 [data-grammar='<name>'] 中使用它们相反,需要格式空格。

我如何在 keymap.cson 配置中使用数据语法选项的示例如下(这里我使用的是 Latex 包):

"atom-text-editor[data-grammar='text tex latex']":
  'f5':'latex:build'

~不是数据语法所需功能的正确语法。相反,使用类似 "atom-text-editor:not([data-grammar='<name>'])": 的内容

请注意,您不会使用 data-grammar类似于 config.cson 。语言细节的语法看起来像这样:

# **config.cson**
".latex.tex.text":
  editor:
    softWrap: true

额外有用的信息 - 已注册语法列表

Object.keys(atom.grammars.grammarsByScopeName).sort().join('\n') 输出的转储通过开发控制台(查看 > 开发人员 > 切换开发人员选项 > 控制台)

source.c
source.cake
source.clojure
source.coffee
source.cpp
source.cs
source.css
source.css.less
source.css.scss
source.csx
source.diff
source.gfm
source.git-config
source.go
source.gotemplate
source.java
source.java-properties
source.js
source.js.rails source.js.jquery
source.js.regexp
source.js.regexp.replacement
source.json
source.litcoffee
source.makefile
source.nant-build
source.objc
source.objcpp
source.perl
source.perl6
source.plist
source.python
source.python.django
source.regexp.python
source.ruby
source.ruby.gemfile
source.ruby.rails
source.ruby.rails.rjs
source.sass
source.shell
source.sql
source.sql.mustache
source.sql.ruby
source.strings
source.toml
source.verilog
source.yaml
text.bibtex
text.git-commit
text.git-rebase
text.html.basic
text.html.erb
text.html.gohtml
text.html.jsp
text.html.mustache
text.html.php
text.html.ruby
text.hyperlink
text.junit-test-report
text.log.latex
text.plain
text.plain.null-grammar
text.python.console
text.python.traceback
text.shell-session
text.tex
text.tex.latex
text.tex.latex.beamer
text.tex.latex.memoir
text.todo
text.xml
text.xml.plist
text.xml.xsl

关于atom-editor - 键绑定(bind)的原子数据语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43008745/

相关文章:

python - 在 Atom 中激活 Python 虚拟环境

syntax - 如何在 Atom 中为 Twig 文件设置默认语法突出显示?

python - Atom 和 Jupyter 找不到使用 pip/pip3 安装的 SimPy 模块

ruby-on-rails - Atom 文本编辑器中文件扩展名冲突时的默认语法

asp.net - 如何通过 Atom 编辑器运行 ASP.NET 5 应用程序?

atom-editor - Atom block 选择附加组件完全丢失?

javascript - 如何像在 chrome 中一样在 node.js 中使用提示功能

linux - 我如何在 AWS 的 amazon linux 上使用 Atom 编辑器?

node.js - 子进程错误 : Error: channel closed - node + atom

Javascript 打开标签不起作用?