Sublime text 2 - 在 Zend Framework 中按类名查找文件 [英] Sublime text 2 - find file by class name in Zend Framework
问题描述
当你按下 Ctrl+p
Sublime 会在你可以轻松找到文件时打开弹出窗口.当您按下 /
或文件路径部分之间的空格时,Sublime 会在两种情况下自动检测文件位置.
When you press Ctrl+p
Sublime will open popup when you can easily find the file. Sublime auto detect the file location in both situation when you press /
or space between file path parts.
在 Zend Framework 中,所有类在以下模板中都有名称:Namespace_Module_Other_Part_Of_Class_Location
,当我按下 Ctrl+ 时,如何让 Sublime 将
并复制过去的类名?_
理解为路径分隔符p
In Zend Framework all classes has name within follow template: Namespace_Module_Other_Part_Of_Class_Location
, how can I make Sublime understand the _
as a path separator when I press Ctrl+p
and copy past the class name there?
所以上面的类应该在位置上被识别:Project/Namespace/Module/Other/Part/Of/Class/Location.php
So the above class should be recognized on location: Project/Namespace/Module/Other/Part/Of/Class/Location.php
我仍在寻找解决方案.即使文件搜索在 Sublime 3 中是硬编码的,并且您有一个解决方法可以使其正常工作,也许可以编写一些插件?不客气.
I'm still looking for the solution of it. Even if the file search is hard-coded in Sublime 3, and you have a workaround to make it works, maybe to write some plugin? you are welcome.
谢谢.
推荐答案
您可以使用简单的插件和键绑定来完成此操作.选择 Tools ->新插件...
并将内容替换为以下内容:
You can do this with a simple plugin and key binding. Select Tools -> New Plugin...
and replace the contents with the following:
import sublime
import sublime_plugin
class UnderscoreToSpaceCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command('copy')
clipboard = sublime.get_clipboard()
clipboard = clipboard.replace('_', ' ')
sublime.set_clipboard(clipboard)
将文件另存为Packages/User/underscore_to_space.py
,其中Packages
是点击Preferences -> 时打开的文件夹.浏览包...
.
Save the file as Packages/User/underscore_to_space.py
where Packages
is the folder opened when clicking on Preferences -> Browse Packages...
.
接下来,为命令创建自定义键绑定.选择 Preferences ->Key Bindings-User
并添加以下内容:
Next, create a custom key binding for the command. Select Preferences -> Key Bindings-User
and add the following:
{ "keys": ["ctrl+shift+c"], "command": "underscore_to_space" }
如果打开文件时文件为空,请用方括号[ ]
将上面的行括起来.保存文件(它会自动保存到正确的位置),你就完成了.
If the file is empty when you open it, surround the above line with square brackets [ ]
. Save the file (it will automatically save to the correct location), and you're all set.
现在,您需要做的就是选择要转换的文本,然后按 CtrlShiftC.这会将文本复制到剪贴板,用空格替换下划线,并将修改后的文本放回剪贴板.您现在可以点击 CtrlP 打开 Goto Anything...
并使用 Ctrl<粘贴修改后的文本kbd>V.
Now, all you need to do is select the text you want to convert, and hit CtrlShiftC. This will copy the text to the clipboard, replace the underscores with spaces, and put the modified text back in the clipboard. You can now hit CtrlP to open Goto Anything...
and paste in the modified text with CtrlV.
如果您希望将下划线替换为正斜杠 /
,只需将 clipboard.replace()
参数从 ('_', ' ')
到 ('_', '/')
.
If you prefer to have the underscores replaces with forward slashes /
, just change the clipboard.replace()
arguments from ('_', ' ')
to ('_', '/')
.
这篇关于Sublime text 2 - 在 Zend Framework 中按类名查找文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!