简单示例:
键盘映射.cson:
"atom-text-editor[data-grammar='text tex latex']":
'f5':'latex:build'
语法信息和文档
我首先查看了file-types https://atom.io/packages/file-types包裹。source
and text
对语言进行分类 -source
处理开发语言,同时text
处理文档/日志格式。
您可以通过阅读飞行手册来添加和自定义语言识别。我在下面链接了一些对此有帮助的特定部分。
飞行手册 |基本定制:
语言识别 http://flight-manual.atom.io/using-atom/sections/basic-customization/#customizing-language-recognition
语言特定设置 http://flight-manual.atom.io/using-atom/sections/basic-customization/#language-specific-settings-in-your-config-file
与...一起工作[data-grammar]
:
给出的小文档列在“深度键盘映射”部分下。
飞行手册 |深度按键映射
选择器和自定义包 http://flight-manual.atom.io/behind-atom/sections/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'
The ~
不是数据语法所需功能的正确语法。相反,使用类似的东西"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