Alt*_*nja 19 php visual-studio-code vscode-settings
我已经启用了“editor.formatOnSave”设置,但是在 php 文件中,当代码格式化时,所有的开括号都将转到新行。我只是想让他们保持在同一行前
function test{
}
Run Code Online (Sandbox Code Playgroud)
不是
function test
{
}
Run Code Online (Sandbox Code Playgroud)
我整天都在寻找解决方案,但我找不到任何东西
Rap*_*let 36
如果你想让你的 php 代码像这样格式化
function test {
}
Run Code Online (Sandbox Code Playgroud)
然后使用具有以下设置的智能电话。
"intelephense.format.braces": "k&r"
Run Code Online (Sandbox Code Playgroud)
正如@Pinonirvana 在他的回答中所说,您现在可以通过 GUI 执行此操作。
您将在 du 用户设置下找到此信息:
快捷键 -> Ctrl+,
或者
文件 > 首选项 > 设置
intelphence 中有默认的格式化程序,它没有很多自定义选项。您可以在特定于 php 语言的设置中禁用它:
~/.config/Code - OSS/User/settings.json:
----------
...
"[php]": {
// "editor.defaultFormatter": "bmewburn.vscode-intelephense-client"
"editor.defaultFormatter": "kokororin.vscode-phpfmt"
},
...
Run Code Online (Sandbox Code Playgroud)
然后您可以使用其他一些支持自定义的格式化程序,例如phpfmt。这是我的设置:
"phpfmt.exclude": [
"AllmanStyleBraces"
],
"phpfmt.smart_linebreak_after_curly": true,
"phpfmt.psr2": false,
"phpfmt.detect_indent": true
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4088 次 |
| 最近记录: |