TextMate Django Tab 触发失败
我刚刚在 Textmate 中安装了 Python Django 和 Django Templates 包。但是,标签触发器似乎不起作用。我打开一个 .py 文件并编写了很多内容并按下了选项卡,但它没有自动完成。
当我从菜单栏中手动单击它时,它工作正常。我是不是忘记了什么?捆绑包是否需要以某种方式激活?
I just installed the Python Django and Django Templates bundles in Textmate. However, the tag triggers dont seem to work. I opened up a .py file and wrote manytomany and pressed tab and it didnt autocomplete.
When i click on it manually from the menu bar it works fine. Am I forgetting something? Do bundles need to be activated somehow?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能存在范围不匹配的情况,即调用该代码片段时所处的范围必须与定义它的范围相匹配。
在您的情况下,“多对多”代码段的默认范围选择器是 source.python.django,但您调用该代码段时可能所处的范围是 source.python,这是打开/创建Python文件时预设的范围。
有两种方法可以解决这个问题,都很简单。首先是改变文档的范围;第二个是更改函数/片段的范围。
要执行第一个操作,只需通过控制栏(位于 TM 文档窗口的最底部)第二个面板(从左侧)的弹出菜单更改与您所在文档相关的语言。当您打开 python (.py) 文档时,默认情况下应将其设置为“Python”。单击“Python”右侧的三角形,然后选择“Python Django”。完成此操作后,在文本区域中键入“manytomany”,然后按 TAB 键,即可执行您想要的操作。
或者,您可以更改代码片段的范围。为此,请打开捆绑包编辑器(“ctrl-option-cmd B”),然后选择“Python Django”,然后选择“ManytoMany”片段。单击 Bundle Editor 窗口右上角的“settings”按钮,然后将 Scope Selector 文本框中的文本更改为“source python”(默认情况下应为“source.python.django”)。
You might have a scope mismatch--i.e., the scope you're in when you invoke that snippet has to match the scope(s) in which it was defined.
In your case, the default scope selector for the 'many-to-many' snippet is source.python.django, yet the scope you were probably in at the time you invoked the snippet was source.python, which is the pre-set scope when you open/create a python file.
There's two ways to deal with this, both are easy. The first is to change the document's scope; the second is to change the function/snippet's scope.
To do the first, just change the language associated with the document you are in via the pop-up menu in second panel (from the left) of the control bar (at the very bottom of the TM document window). When you open a python (.py) document, it should be set to "Python" by default. Click the triangles just to the right of "Python" and select "Python Django". Once you've done that, then typing "manytomany" in the text area then hitting TAB, will do what you want.
Alternatively you can change the snippet's scope. To do this, open the Bundle Editor ("ctrl-option-cmd B"), then select "Python Django" then the "ManytoMany" snippet. Click the "settings" button at the upper right of the Bundle Editor window, then change the text in the Scope Selector text box to read "source python" (by default it should read "source.python.django").
您确定简写是
manytomany
吗?在我的包中,它是mtm
。尝试编辑该包以查看简写触发器字符串是什么。Are you sure the shorthand is
manytomany
? in my bundle, it'smtm
. Try editing the bundle to see what the shorthadn trigger strings are.