如何防止PhpStorm重新分配文件类型?

问题描述 投票:5回答:1

我目前正在评估PhpStorm作为Aptana Studio的替代品,我们现在就使用它。但有一个问题真的很烦人。

我们为PHP模板使用* .tpl文件扩展名。此文件类型通常映射到Smarty。将其设置为“PHP文件(PHP)”非常容易。但是每次我重新启动PhpStorm时,都会收到以下消息:

File type recognized: File extension *.tpl was reassigned to Smarty

所以它将文件类型映射回Smarty。如果我尝试通过“事件日志”“恢复”它,它将把它映射到“文本文件”,但不会回到PHP。

那么,我如何防止PhpStorm触及我的手动更改是保持映射到PHP(而不是Smarty)?

phpstorm
1个回答
4
投票

所以以下方法可行:

无需触摸配置:

  1. 通过Preferences > Editor > File Types设置更改文件类型映射
  2. 重启PhpStorm
  3. 一旦出现“文件类型识别”消息,请单击“还原”链接(请参阅问题)
  4. 重做步骤1

现在PhpStorm不应该再将它映射回来。

触摸配置文件:

在您的用户配置文件中,您应该有一个文件夹.WebIde70/config/options(或类似的东西),你应该有一个名为filetypes.xml的文件(如果没有创建一个空文件),你可以在其中设置映射并阻止PhpStorm恢复它。这是一个简单的例子,只有我的问题的映射:

<?xml version="1.0" encoding="UTF-8"?>
<application>
  <component name="FileTypeManager" version="11">
    <ignoreFiles list="CVS;SCCS;RCS;rcs;.DS_Store;.svn;.pyc;.pyo;*.pyc;*.pyo;.git;*.hprof;_svn;.hg;*.lib;*~;__pycache__;.bundle;*.rbc;" />
    <extensionMap>
      <mapping ext="tpl" type="PHP" />
      <removed_mapping ext="tpl" approved="true" type="Smarty" />
    </extensionMap>
  </component>
</application>

如您所见,设置文件不仅设置新映射,还删除Smarty模板的原始映射。

© www.soinside.com 2019 - 2024. All rights reserved.