Visual Studio 2017中TypeScript代码无法使用Ctrl+E,D格式化
It sounds like your keyboard shortcut bindings got messed up after the system reinstall—since you could format TypeScript code before, this is almost certainly a configuration issue rather than a core bug. Here's how to resolve it step by step:
1. Verify and Fix Shortcut Bindings
The error means the Format Document command isn't properly mapped to Ctrl+E,D for TypeScript files in your VC# 2005 shortcut scheme. Let's correct that:
- Open Tools > Options > Environment > Keyboard
- In the "Show commands containing" box, type
Edit.FormatDocument - In the "Use new shortcut in" dropdown, select Text Editor (or specifically TypeScript Editor if you want it scoped only to TS files)
- Click inside the "Press shortcut keys" box, then press
Ctrl+E, release both, then pressD - Click Assign to save the binding, then hit OK to close the options window.
2. Ensure TypeScript Language Services Are Installed and Enabled
A system reinstall might have missed some VS components needed for TypeScript formatting:
- Open the Visual Studio Installer from your Start menu
- Select your VS2017 Enterprise installation, then click Modify
- Check that the ASP.NET and Web Development workload is installed (this includes TypeScript support)
- If it's missing, select it and click Modify to install. Once done, restart VS.
- Also, double-check formatting is enabled for TypeScript: Go to Tools > Options > Text Editor > TypeScript > Formatting and ensure all formatting options are toggled on.
3. Repair Your Visual Studio Installation
If the above steps don't work, a corrupted VS installation could be the culprit:
- Open the Visual Studio Installer again
- Select your VS2017 installation, click More > Repair
- Let the repair process run (this might take a while), then restart your computer and launch VS again.
After trying these steps, test Ctrl+E,D in a TypeScript file—your formatting should work as it did before the system reinstall.
内容的提问来源于stack exchange,提问作者Erez Shlomo

