PHPStorm 常用设置
参考版本 2019.3, 箭头(->)表示菜单顺序
常用设置菜单路径
-
修改主题:
Apperance & Behavior -> Apperance -> UI Options -> Theme -
代码自动(软)换行:
Setting ->Editor -> General -> Soft Wraps-> 选择"Use soft wraps in editor", (新版本是"Soft-wrap files *", 添加需要自动换行的文件扩展名) -
修改代码字体:
Setting ->Editor -> General -> Font -
注释用斜线不在行头:
Setting ->Editor -> Code Style -> PHP -> Wrapping and Braces -> Keep when reformatting-> 取消"Comment at first column"以及:
Setting ->Editor -> Code Style -> PHP -> Code Generation -> Comment Code-> 取消 “Line comment at first column”同时:
Setting ->Editor -> Code Style -> HTML -> Code Generation-> Comments 下取消"Line commment at first column" 和 “Block commment at first column” -
代码自动完成的大小写区分取消:
Setting ->Editor -> General -> Code Completion-> 取消 “Math case” -
大括号不换行
Setting ->Editor -> Code Style -> PHP -> Wrapping and Braces -> Braces placement -> In class declaration 和 In function declaration选择 End of line -
EOL设置为unix格式:
Setting ->Editor -> Code Style -> General -> Line Separtor选择 “Unix and macOS(\n)” -
取消HTML属性的自动换行:
Setting -> Editor -> Code Style -> HTML -> Other -> Wrap attributes设置为 “Do not wrap”, 并取消"Wrap text".
(那个"Hard wrap at"的默认值120在Editor -> Code Style -> Hard wrap at, 最大值是1000) -
取消输入引号时的自动补充:
Setting ->Editor -> General -> Smart Keys取消 “Surround selection on typeing quote or brace” -
选中相同文字高亮:
Setting ->plugins-> 搜索BrowseWordAtCaret安装,然后重启; 然后进入Settings -> Editor -> General -> Appearance -> Browse Word At Caret勾选。
如果想修改默认的颜色,在Settings -> Editor -> Colors & Font或者Color Scheme -> BrowseWordAtCaret中进行修改,可以改成亮点的颜色。 -
else换行(不建议修改)
Setting ->Editor -> Code Style -> PHP-> Warpping and Braces -> ‘if()’ statement -> 选中 “‘else’ on new line” -
修改搜索结果只显示前100个(100+ matches)的问题:
顶部
Help菜单 ->Edit Custom VM Options, 添加一行-Dide.usages.page.size=500就改成500了, 重启. (2019.3版本测试没问题)2021.2 版本中新增了设置
Settings -> Advanced Settings -> Maximum number of results to show in Find In Path/Show Usages preview可以直接改. -
调整/关闭 SQL 代码背景色
Setting -> Editor -> Color Scheme -> General -> Code -> “Injected language fragment”,右边的 “Background” 复选框可以取消,或者选中后再选择一个自己喜欢的颜色。
- 显示所有参数提示 (默认只显示非变量传入的参数提示)
Setting -> Editor -> Inlay hints -> PHP -> 选中 “Show name for all arguments”
或者: 在 “setting” 中 搜索"show parameter hints", 然后找到 “PHP” 对应的记录, 选中 “Show name for all arguments”
-
CSS代码保留单行块 (对html中的style块比较友好)
Settings -> Editor -> Code Style -> Style Sheets -> CSS在Other标签下, 下勾选 “Keep single-line blocks” -
HTML中部分标签的子标签不缩进
Settings -> Editor -> Code Style -> HTML在Other标签下, 在Do not indent children of里面添加不想缩进的标签, 比如: head
关闭不常用的代码检查
-
对于thinkphp orm的
table方法引起的"Non-static method ‘table’ should not be called statically, but clas has _magic"错误, 暂时取消Editor -> Inspections -> PHP-> General ->"Dynamic method called as static" -
Editor->Inspection->SQL:- No data sources configured
- SQL dialect detection.
-
Editor->Inspection->HTML:- Anchor reference problems
- File reference problems
- Form input without an associated label or title attribute
- Image size mismatch
- Missing required attribute
- Presentational HTML tag
- Quirks mode(兼容模式检查).
-
Editor->Inspection->CSS:- Unused CSS selector.
-
Editor->Inspection->CSS->Probable bugs:- Missing generic font name.
-
Editor->Inspection->Javascript->ECMScript 6 migration aids:- ‘var’ used instead of ‘let’ or ‘const’.
-
Editor->Inspection->PHP: Statement has empty body:- Comments count as content