Is there a way to get a list of Monaco's available commands/actions and their IDs, like editor.action.formatDocument
?
There doesn't seem to be anything in the documentation and I'm struggling to find registered actions and commands in the VS Code repository. The Command Palette shows most of them, but there's no indication of their IDs if you want to manually call them with executeCommand
.
Is there a way to get a list of Monaco's available commands/actions and their IDs, like editor.action.formatDocument
?
There doesn't seem to be anything in the documentation and I'm struggling to find registered actions and commands in the VS Code repository. The Command Palette shows most of them, but there's no indication of their IDs if you want to manually call them with executeCommand
.
2 Answers
Reset to default 23editor.getSupportedActions()
is what I was looking for.
You can use it like this to get a list of action IDs:
let actions = editor.getSupportedActions().map((a) => a.id);
console.log(actions);
Which returns a list like this in my current Monaco setup:
[
"actions.find",
"actions.findWithSelection",
"cursorRedo",
"cursorUndo",
"deleteAllLeft",
"deleteAllRight",
"editor.action.addCommentLine",
"editor.action.addCursorsToBottom",
"editor.action.addCursorsToTop",
"editor.action.addSelectionToNextFindMatch",
"editor.action.addSelectionToPreviousFindMatch",
"editor.action.blockComment",
"editor.action.clipboardCopyWithSyntaxHighlightingAction",
"editor.action.commentLine",
"editor.action.copyLinesDownAction",
"editor.action.copyLinesUpAction",
"editor.action.deleteLines",
"editor.action.detectIndentation",
"editor.action.duplicateSelection",
"editor.action.fontZoomIn",
"editor.action.fontZoomOut",
"editor.action.fontZoomReset",
"editor.action.formatDocument",
"editor.action.formatSelection",
"editor.action.gotoLine",
"editor.action.goToReferences",
"editor.action.indentationToSpaces",
"editor.action.indentationToTabs",
"editor.action.indentLines",
"editor.action.indentUsingSpaces",
"editor.action.indentUsingTabs",
"editor.action.inPlaceReplace.down",
"editor.action.inPlaceReplace.up",
"editor.action.insertCursorAbove",
"editor.action.insertCursorAtEndOfEachLineSelected",
"editor.action.insertCursorBelow",
"editor.action.insertLineAfter",
"editor.action.insertLineBefore",
"editor.action.inspectTokens",
"editor.action.joinLines",
"editor.action.jumpToBracket",
"editor.action.marker.next",
"editor.action.marker.nextInFiles",
"editor.action.marker.prev",
"editor.action.marker.prevInFiles",
"editor.action.moveCarretLeftAction",
"editor.action.moveCarretRightAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesUpAction",
"editor.action.moveSelectionToNextFindMatch",
"editor.action.moveSelectionToPreviousFindMatch",
"editor.action.nextMatchFindAction",
"editor.action.nextSelectionMatchFindAction",
"editor.action.onTypeRename",
"editor.action.openLink",
"editor.action.outdentLines",
"editor.action.peekDefinition",
"editor.action.previousMatchFindAction",
"editor.action.previousSelectionMatchFindAction",
"editor.action.quickCommand",
"editor.action.quickFix",
"editor.action.quickOutline",
"editor.action.refactor",
"editor.action.referenceSearch.trigger",
"editor.action.reindentlines",
"editor.action.reindentselectedlines",
"editor.action.removeCommentLine",
"editor.action.rename",
"editor.action.revealDefinition",
"editor.action.revealDefinitionAside",
"editor.action.selectHighlights",
"editor.action.selectToBracket",
"editor.action.setSelectionAnchor",
"editor.action.showAccessibilityHelp",
"editor.action.showContextMenu",
"editor.action.showDefinitionPreviewHover",
"editor.action.showHover",
"editor.action.smartSelect.expand",
"editor.action.smartSelect.shrink",
"editor.action.sortLinesAscending",
"editor.action.sortLinesDescending",
"editor.action.sourceAction",
"editor.action.startFindReplaceAction",
"editor.action.toggleHighContrast",
"editor.action.toggleTabFocusMode",
"editor.action.transformToLowercase",
"editor.action.transformToTitlecase",
"editor.action.transformToUppercase",
"editor.action.transpose",
"editor.action.transposeLetters",
"editor.action.triggerParameterHints",
"editor.action.triggerSuggest",
"editor.action.trimTrailingWhitespace",
"editor.action.wordHighlight.trigger",
"editor.fold",
"editor.foldAll",
"editor.foldAllBlockComments",
"editor.foldAllMarkerRegions",
"editor.foldLevel1",
"editor.foldLevel2",
"editor.foldLevel3",
"editor.foldLevel4",
"editor.foldLevel5",
"editor.foldLevel6",
"editor.foldLevel7",
"editor.foldRecursively",
"editor.toggleFold",
"editor.unfold",
"editor.unfoldAll",
"editor.unfoldAllMarkerRegions",
"editor.unfoldRecursively"
]
Or you can use:
let actions = editor.getActions();
console.log(actions);
let actions = editor._actions;
console.log(actions);