29
我想为Atom编写一个命令,它包含两个或多个预先存在的命令,如“选择线”和“剪切”。我怎么做?如何在Atom中编写自定义命令?
我想为Atom编写一个命令,它包含两个或多个预先存在的命令,如“选择线”和“剪切”。我怎么做?如何在Atom中编写自定义命令?
您可以将下面的代码添加到您的init.coffee
文件:
atom.commands.add 'atom-text-editor', 'custom:cut-line', ->
editor = atom.workspace.getActiveTextEditor()
editor.selectLinesContainingCursors()
editor.cutSelectedText()
可以让代码通过搜索命令面板串从源头上执行。一旦你有一个命令创建的,您可以通过编辑keymap.cson
文件映射键一下:
'atom-text-editor':
'alt-cmd-z': 'custom:cut-line'
我发现的代码在原子/ src目录/ [register-default-commands.coffee]的命令(HTTPS ://github.com/atom/atom/blob/f376316d60b7b0e96ceaff8c631ea6458f31907c/src/register-default-commands.coffee) – pguardiario
我想使用已安装的软件包进行组合命令。我如何去使用非编辑器命令? – Erich
@Erich也许这个答案会帮助你? https://stackoverflow.com/a/27230783/6426778 – Tweakimp