如何打开包含活动Eclipse编辑器文件的外部Vim编辑器 [英] How do you open an external Vim editor containing the active Eclipse editor file
问题描述
有没有一个快捷方便的方法?
Canonical Way
- 窗口>首选项...折叠一般>编辑>文件关联。
- 选择要编辑的文件类型
- 点击关联编辑器框旁边的添加按钮
- 点击外部程序和浏览...,然后找到gvim,或者输入/ usr / bin / gvim,或者通常使用gvim。
现在,该类型的文件应显示在外部的vim实例中。真棒,对吧?但是,这并不能解决您将当前缓冲区推送到vim的问题。
Hack
相反,我们将将vim设置为构建工具,并将eclipse将当前文件作为参数发送。这可能会有一些不受影响的副作用,基于您的项目设置,但如果您遇到意外的重新构建文件,请仔细查看。
- 运行>外部工具>外部工具配置...
- 选择左侧的程序,然后单击新建图标。
- 输入发送到vim的名称
- 输入/ usr / bin / gvim(或其他路径是)位置
- 在工作目录下输入
$ {project_loc}
(这是一个代表项目顶级目录的变量) - 输入
$ {resource_loc}
(这表示您当前的资源路径) - 在Build选项卡上,取消选中Build before启动(除非您真的想要)
- 在常用选项卡上,选中显示在收藏夹菜单下的外部工具
你应该全部设置!现在,您可以使用菜单
将$文件发送到vim 运行>外部工具>发送到vim
如果你想要花哨,你甚至可以添加一个按钮到你的工具栏。 / p>
建议,我在示例中使用了gvim。如果您想使用终端vim,则必须根据您使用的终端进行适当的呼叫。对于xterm,这将是 / usr / bin / xterm -e / usr / bin / vim
,而不是 / usr / bin / gvim
I'm not looking for an "Vim Plugin" for Eclipse. Instead, I'd just want a keyboard-shortcut to open the current Eclipse file within a new Vim instance.
Is there a quick and easy way to do that?
There's two ways to do this, the canonical way, and the hack. First:
The Canonical Way
- Window > Preferences... Fold out General > Editors > File Associations.
- Choose the file type you want to edit
- Click the "Add" button beside the "Associated editors" box.
- Click "External programs" and "Browse...", then find gvim, or enter /usr/bin/gvim, or generally make it go to gvim.
Now, files of that type should show up in an external vim instance. Awesome, right? But that doesn't solve your problem of pushing the current buffer out to vim.
The Hack
Instead, we're going to set vim as a "build tool", and have eclipse send it the current file as arguments. This may have some unaffected side-effects, based on your project settings, but look into them carefully if you experience things like unexpected re-building of your files.
- Run > External Tools > External Tools Configuration...
- Select "Program" on the left and click the "New" icon.
- Enter "Send to vim" for the Name
- Enter "/usr/bin/gvim" (or whatever your path is) for the Location
- Under "Working Directory" enter
${project_loc}
(this is a variable representing your project's top directory) - Under arguments enter
${resource_loc}
(this represents your current resource's path) - On the "Build" tab, un-check "Build before Launch" (unless you really want that)
- On the Common tab, check "External Tools" under the "Display in favorites menu"
You should be all set! Now you can send your file to vim by using the menu
Run > External Tools > Send to vim
If you want to get fancy, you can even add a button to your toolbar.
Be advised, I've used gvim in the examples. If you'd like to use terminal vim, you'll have to call it appropriately based on the terminal you're using. For xterm, this would be /usr/bin/xterm -e /usr/bin/vim
, instead of /usr/bin/gvim
这篇关于如何打开包含活动Eclipse编辑器文件的外部Vim编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!