且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Atom中编写自定义命令?

更新时间:2022-12-11 18:00:38

您可以将以下代码添加到您的init.coffee文件中:

You can add the following code to your init.coffee file:

atom.commands.add 'atom-text-editor', 'custom:cut-line', ->
  editor = atom.workspace.getActiveTextEditor()
  editor.selectLinesContainingCursors()
  editor.cutSelectedText()

您可以通过在命令面板中搜索字符串来从源代码中执行代码.一旦创建了命令,就可以通过编辑keymap.cson文件来将键映射到它:

You can get the code to execute from the source by searching for strings in the command palette. And once you have a command created, you can map a key to it by editing your keymap.cson file:

'atom-text-editor':
    'alt-cmd-z': 'custom:cut-line'