LoginSignup
9
9

More than 5 years have passed since last update.

1つのキーバインドで、同時に複数のコマンドを実行する

Posted at

keymap.cson にキーバインドを登録できるが、複数登録されている場合、別のキーバインドを上書きする動作になり、複数コマンドを実行することができない。

この場合の対処は、公式によると、init.coffeeに新しく複数コマンドを実行するコマンドを作って、そのコマンドを登録するとのこと。

自分は、cmd-sで、保存とvim-modeのinsertモードを抜けるコマンドが欲しかったので、custom:save-and-normalmodeのコマンドを追加した。

init.coffee
atom.commands.add 'atom-text-editor.vim-mode', 'custom:save-and-normalmode', ->
  view = atom.views.getView atom.workspace.getActiveTextEditor()
  atom.commands.dispatch view, 'core:save'
  atom.commands.dispatch view, 'vim-mode:reset-normal-mode'

これをキーバインドに追加する。

keymap.cson
# 保存時にノーマルモードに戻る
'atom-text-editor.vim-mode':
  'cmd-s': 'custom:save-and-normalmode'

なお、init.coffeeはAtomを再起動しないと有効にならない。

これを簡単にできるプラグインとかできないかな。

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9