我正在开发一个关于Visual Studio Code的Angular项目,我在Typescript文件上获得了一个令人讨厌的格式文档设置,它将参数分解为一个新行:
格式化之前(alt shift f):
this.opportunityId = this.route.snapshot.paramMap.get('opportunityid');
this.opportunityTermVendorId = this.route.snapshot.paramMap.get('vendorid');
this.opportunityTermVendorAssetId = this.route.snapshot.paramMap.get('assetid');
this.opportunityTermCollateralId = this.route.snapshot.paramMap.get('collateralid');
格式化后(alt shift f):
this.opportunityId = this.route.snapshot.paramMap.get('opportunityid');
this.opportunityTermVendorId = this.route.snapshot.paramMap.get('vendorid');
this.opportunityTermVendorAssetId = this.route.snapshot.paramMap.get(
'assetid'
);
this.opportunityTermCollateralId = this.route.snapshot.paramMap.get(
'collateralid'
);
我关闭了自动换行功能,但我仍然尝试将其设置为更大的自动换行列值 . 查看我当前的设置覆盖
{
"git.confirmSync": false,
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"workbench.iconTheme": "material-icon-theme",
"editor.formatOnSave": true,
"prettier.singleQuote": true,
"editor.wordWrapColumn": 180
}
3 回答
我发现“Angular Essentials”附带的名为“Prettier”的扩展程序引发了这个问题 . 我只需要在设置中添加“prettier.printWidth”:160 .
根据this
你应该设置:
对我来说
"prettier.printWidth": 180
并没有"prettier"在每个属性的开头都有"prettier"部分 .所以在
.prettierrc
我现在有"printWidth": 180
修复了这个问题 .