Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Commit

Permalink
Add some emacs shortcuts.
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-shatskyi committed Sep 15, 2017
1 parent aeab81f commit 32f415d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/views/PromptComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,30 @@ export class PromptComponent extends React.Component<Props, State> {
() => this.setNextHistoryItem(),
"!suggestWidgetVisible",
);
this.addShortcut(
monaco.KeyMod.WinCtrl | monaco.KeyCode.KEY_B,
"cursorLeft",
);
this.addShortcut(
monaco.KeyMod.Alt | monaco.KeyCode.KEY_B,
"cursorWordStartLeft",
);
this.addShortcut(
monaco.KeyMod.WinCtrl | monaco.KeyCode.KEY_F,
"cursorRight",
);
this.addShortcut(
monaco.KeyMod.Alt | monaco.KeyCode.KEY_F,
"cursorWordEndRight",
);
this.addShortcut(
monaco.KeyMod.WinCtrl | monaco.KeyCode.KEY_W,
"deleteWordLeft",
);
this.addShortcut(
monaco.KeyMod.Alt | monaco.KeyCode.KEY_D,
"deleteWordRight",
);

this.focus();
}
Expand Down Expand Up @@ -217,4 +241,12 @@ export class PromptComponent extends React.Component<Props, State> {
private triggerSuggest() {
this.editor.trigger(this.editor.getValue(), "editor.action.triggerSuggest", {});
}

private addShortcut(keybinding: number, handlerId: string) {
this.editor.addCommand(
keybinding,
() => this.editor.trigger("", handlerId, {}),
"",
);
}
}

0 comments on commit 32f415d

Please sign in to comment.