如何在PhpStorm/WebStorm实现打开新标签时关闭未修改标签的功能?
Got it, let's get this sorted! If you're missing that convenient behavior from Sublime or VSCode where unmodified tabs auto-close when you open a new file, PhpStorm and WebStorm absolutely support this—you just need to flip a few settings. Here's how:
First, open your IDE's Settings/Preferences:
- On Mac: Use the shortcut
Cmd+,or go to PhpStorm/WebStorm > Preferences from the menu bar - On Windows/Linux: Hit
Ctrl+Alt+Sor select File > Settings
- On Mac: Use the shortcut
Navigate to the Editor > General > Editor Tabs section in the settings menu.
Scroll down to the Close tabs automatically area, then check the box for Close tabs that were opened from the project view and haven't been modified.
That's it! Now, any tab you open from the project explorer that you don't make changes to will automatically close when you open a new file—exactly like the behavior you're used to. And just like in Sublime/VSCode, if you want to keep an unmodified tab around, simply hit Cmd+S (Mac) or Ctrl+S (Windows/Linux) to "save" it (even if there are no changes, this marks the tab as modified and prevents auto-closing).
If you want to tweak further, you can also adjust the Maximum number of tabs setting in the same section to limit how many tabs stay open at once, but the core auto-close for unmodified tabs is handled by that first checkbox.
内容的提问来源于stack exchange,提问作者Reacting




