visual-studio-codesettingsvscode-extensionsvscode-keybinding

How can I add other languages to the CTRL+ALT+Win+N shortcut drop-down menu in VS Code?


In VS Code, when I press CTRL+ALT+Win+N I get a prompt at the top of the screen to create a new file with a specific language; I only have Python showing up as an option as that's what I started learning with and set as my default language. I'd like to add other languages to his shortcut drop-down menu that I can then click, specifically HTML right now.

enter image description here

So in the screenshot, I'd like to add other languages under Python (or arranged alphabetically, whatever is default), but I haven't been able to find the setting to do this. Any idea where that is? I know I can do CTRL+K M, but I'm hoping I can simply press CTRL+ALT+Win+N then arrow-key down and hit enter rather than scrolling through the CTRL+K M menu for the new file.

Is there a setting to "favorite" certain languages?

I've tried searching on stackoverflow, google, VSC's page.


Solution

  • As a prefacing FYI, VS Code is capable of detecting a language mode based on file contents.

    The command for opening that menu that you've shown is Create: New File, which has a command ID of welcome.showNewFileEntries. I don't think this menu is really for basic language mode selection. For that, you can just create a new untitled file and then select the language mode after creating it by using the Change Language Mode command in the command palette.

    The Create: New File command seems to be geared toward more custom cases, and requires writing an extension.

    The source code for this command can be found at src/vs/workbench/contrib/welcomeViews/common/newFile.contribution.ts. For your concern, see in particular the line that does MenuRegistry.appendMenuItem(MenuId.NewFile. If you search for MenuId.NewFile, you can see the registration of that menu ID in src/vs/workbench/services/actions/common/menusExtensionPoint.ts (its menu ID is "file/newfile"). So general process of adding to menus in VS Code applies.

    You can see an example of how the builtin ipynb extension implements adding to that menu. It registers its menu contribution to file/newFile in its extension manifest, registers related translation info in its package.nls.json file, and registers the implementation of the command for that menu item in extensions/ipynb/src/ipynbMain.ts. How you implement that command part is up to your extension.

    Note that there is a feature request asking that users be able to configure menus without having to do so through extensions: User configurable menus #9285. If you'd like that feature to be implemented, I suggest that you give that issue ticket a thumbs up to show support for it. You can also subscribe to it to get notified about discussion and progress. Please avoid making noisy comments there like ones that just consist of "+1" / "bump".