如何打开包含活动Eclipse编辑器文件的外部Vim编辑器 [英] How do you open an external Vim editor containing the active Eclipse editor file

查看:189
本文介绍了如何打开包含活动Eclipse编辑器文件的外部Vim编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是在为Eclipse寻找Vim Plugin。相反,我只想要一个键盘快捷方式在新的Vim实例中打开当前的Eclipse文件。



有没有一个快捷方便的方法?

解决方案



Canonical Way




  1. 窗口>首选项...折叠一般>编辑>文件关联。

  2. 选择要编辑的文件类型

  3. 点击关联编辑器框旁边的添加按钮

  4. 点击外部程序和浏览...,然后找到gvim,或者输入/ usr / bin / gvim,或者通常使用gvim。

现在,该类型的文件应显示在外部的vim实例中。真棒,对吧?但是,这并不能解决您将当前缓冲区推送到vim的问题。






Hack



相反,我们将将vim设置为构建工具,并将eclipse将当前文件作为参数发送。这可能会有一些不受影响的副作用,基于您的项目设置,但如果您遇到意外的重新构建文件,请仔细查看。


  1. 运行>外部工具>外部工具配置...

  2. 选择左侧的程序,然后单击新建图标。

  3. 输入发送到vim的名称

  4. 输入/ usr / bin / gvim(或其他路径是)位置

  5. 在工作目录下输入 $ {project_loc} (这是一个代表项目顶级目录的变量)

  6. 输入 $ {resource_loc} (这表示您当前的资源路径)

  7. 在Build选项卡上,取消选中Build before启动(除非您真的想要)

  8. 在常用选项卡上,选中显示在收藏夹菜单下的外部工具

你应该全部设置!现在,您可以使用菜单

将$文件发送到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

  1. Window > Preferences... Fold out General > Editors > File Associations.
  2. Choose the file type you want to edit
  3. Click the "Add" button beside the "Associated editors" box.
  4. 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.

  1. Run > External Tools > External Tools Configuration...
  2. Select "Program" on the left and click the "New" icon.
  3. Enter "Send to vim" for the Name
  4. Enter "/usr/bin/gvim" (or whatever your path is) for the Location
  5. Under "Working Directory" enter ${project_loc} (this is a variable representing your project's top directory)
  6. Under arguments enter ${resource_loc} (this represents your current resource's path)
  7. On the "Build" tab, un-check "Build before Launch" (unless you really want that)
  8. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆