是否可以设置键盘快捷键(或者在某处添加一些菜单项)以在外部编辑器中打开当前编辑的文件?
(显然我可以做[(在文件树中右键单击→在Finder中显示)/(在窗口标题中单击右键→选择包含目录)]→右键单击文件→打开方式→“应用程序”-但步骤太多。 )
呵呵,我找到了。
粘贴此代码(用您的编辑器替换 MacVim)
tell application "Xcode"
set current_document to last source document
set current_document_path to path of current_document
end tell
tell application "MacVim"
activate
open current_document_path
end tell
保存工作流程。
我从这个项目中借用了 AppleScript 代码:Uncrustify Automator Services for Xcode 4。
更好的解决方案是直接在键盘首选项窗格中添加键盘快捷键:
因为我使用选项卡,所以我渴望一个不会从第一个选项卡打开文档的解决方案。我最终得到以下结果:
注意:如果打开了助手编辑器,无论哪个编辑器处于活动状态,标准编辑器(左侧)中的文件都会打开,但对我来说它比第一个选项卡更好。
on run {input, parameters}
set current_document_path to ""
tell application "Xcode"
set last_word_in_main_window to (word -1 of (get name of window 1))
if (last_word_in_main_window is "Edited") then
display notification "Please save the current document and try again"
-- eventually we could automatically save the document when this becomes annoying
else
set current_document to document 1 whose name ends with last_word_in_main_window
set current_document_path to path of current_document
end if
end tell
tell application "MacVim"
if (current_document_path is not "") then
activate
open current_document_path
end if
end tell
return input
end run
我真的很喜欢Fjölnir提出的解决方案,所以要扩展如何做到这一点。
External
如果您为此使用 MacVim,则可以通过将外部编辑器配置为在最后一个窗口关闭后保持运行来改善外部编辑器的加载时间。
现在,当我按下⌥E
弹出窗口时,我进行了更改,:q
然后焦点返回到 Xcode。