Vim& Java:自动添加java import语句 [英] Vim & Java: add java import statements automatically

查看:1242
本文介绍了Vim& Java:自动添加java import语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提示。错误为E349:没有标识符光标,E433 :没有标签文件和E426:标签未找到:公共。我觉得他们无关,或者我无法理解他们的信息。我的代码在〜/ .vimrc中并按下F1,F9和ESC。 相关提示,但更高级。那么如何在Vim中自动添加Java import语句呢?

The tip. The errors are "E349: No identifier unders cursor", "E433: No tags file" and "E426: tag not found: public". I feel them unrelated or I cannot understand their message. I have the code in "~/.vimrc" and pressed "F1", "F9" and "ESC". A related tip but more advanced. so how can I add Java import statements automatically in Vim?

[已添加] 我在侧面使用Eclipse但是当它关​​闭时或者-slow-or-compiling-or-doning-something-stupid我使用Vim。所以停在这里。有什么错误?

[Added] I use Eclipse on the side but when it is down-or-slow-or-compiling-or-doning-something-stupid I use Vim. So stop here. What are the errs for?

推荐答案

游标需要超过标识符

似乎提示要求您将光标放在类名上,然后它将插入import语句。当游标在光标下没有单词时尝试使用< C-W>} 命令时,游标下没有标识符 - 错误显示。

It seems like the tip requires you to position the cursor over a class name for which it will then insert the import statement. "No identifier under cursor"-error shows up when the mapping tries to use the <C-W>} command when there is no word under the cursor.

ctags

显示其他错误,因为它还使用命令< C-W>} ,要求您有一个包含项目标签的ctags文件。这可以使用ctags实用程序生成。丰富的ctags非常适合这个目的:

The other errors show up because it also uses the command <C-W>} which requires you to have a ctags file containing the tags for the project. That can be generated with a ctags utility. Exuberant ctags is quite nice for that purpose:

http:/ /ctags.sourceforge.net/

这里有一些关于为java使用ctags的信息(虽然在我的系统上我没有命令exuberant-ctags ,它只是ctags):

Here is some information about using ctags for java (although on my system I don't have a command exuberant-ctags, it's just ctags):

http://blog.vinceliu.com/2007/08/vim-tips-for-java-2-using-exuberant.html

提示质量

看起来该提示中的映射破坏了默认寄存器,搜索寄存器并更改最后一个更改命令,跳转堆栈,标记堆栈并移动光标。所以这是一个快速的肮脏提示,不是很优雅。

It looks like the mapping in that tip clobbers the default register, search register and changes the last change command, the jump stack, the tag stack and moves the cursor. So it's a quick'n dirty tip, not very elegant.

这篇关于Vim&amp; Java:自动添加java import语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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