使用外部文件或项目中包含的文件完成?
有谁知道如何让 TextMate 搜索外部文件(甚至 TextMate“项目”中包含的文件)来执行单词补全?
我正在 C64 上编写一些内容(使用 TextMate 编写代码),并且我有一个外部文件,其中包含所有硬件寄存器/内核例程的标签,例如,
VIC2InteruptStatus = $D019
能够键入“VIC2I”将非常方便' 然后按单词完成键并让 TextMate 在外部库文件中查找匹配项。而不是我现在必须通过打开库文件并将寄存器名称复制粘贴到我的代码中来完成此操作。
Does anyone know how to get TextMate to search an external file (or even the files contained in a TextMate "project") with which to perform word completion?
I'm coding some stuff on the C64 (using TextMate to write the code) and I have an external file containing labels for all of the hardware registers/kernal routines e.g
VIC2InteruptStatus = $D019
It would be really handy to be able to type, say, 'VIC2I' then press the key for word completion and have TextMate find matches in the external library file. Rather than how I'm having to do it at the moment by opening the library file and copy-paste the register names into my code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一番相当多的尝试和错误后,我得到了这个工作......有点。
您首先需要一个适合您的语言/文件类型的捆绑包。然后在该捆绑包中,您需要使用捆绑包编辑器添加新的“首选项”。根据您的喜好命名,然后跳到编辑窗格并添加它;
{completionCommand = 'grep -oh "\w*${TM_CURRENT_WORD}\w*" FILESPEC |排序| uniq';}
其中 FILESPEC 是一个包含您想要提供的用于单词完成的关键字的单个文件。
关闭捆绑包编辑器。
现在,如果您开始键入 FILESPEC 文件中的单词,请按 ESC(或您已将补全映射到的任何键),TextMate 将提供按字母顺序排序的单词补全。按住 ESC 键可循环显示所有匹配项(SHIFT+ESC 向后移动)。
我不明白的是如何使搜索不区分大小写。您可以在 GREP 中使用 -i 选项,但 -o 选项会覆盖它。理想情况下,如果您输入;
com
康姆
COM
它将查找外部文件中以字母 c、o、m 开头的所有单词。相反,如果您输入“COM”,它只会匹配以“COM”开头的单词,而不匹配“com”或“Com”等。
如果任何更精通 GREP 的人能够弄清楚这一点,我将非常感激。
After some considerable trial and error I got this working....kind of.
You first need an appropriate Bundle for your language/file type. Then within that Bundle you need to use the Bundle Editor to add a new "Preference". Name it however you like and then jump across to the editing pane and add this;
{completionCommand = 'grep -oh "\w*${TM_CURRENT_WORD}\w*" FILESPEC | sort | uniq';}
where FILESPEC is either a single file that contains the keywords you'd like to be offered for word completion.
Close the Bundle Editor.
Now if you start typing a word that is in the FILESPEC file, press ESC (or whatever key you've got Completion mapped to) and TextMate will offer alphabetically sorted word completion. Keep pressing ESC to cycle through all the matches (SHIFT+ESC goes backwards).
Something I couldn't figure out was how to make the search case insensitive. You can use the -i option in GREP but the -o option overrides it. Ideally, if you typed;
com
Com
COM
it would find all the words in the external file that begin with the letters c, o, m. Instead, if you type "COM" it will only match words that start with "COM" and not "com" or "Com" etc.
If anyone who has more mastery of GREP could figure that out I'd be very grateful.