Vim - 以当前文件作为参数运行 ant 命令
在我的 IDE (webstorm) 中,我配置了一个外部工具来运行 ant,如下所示:
ant myTarget -DfileNoExt="$FileNameWithoutExtension$"
运行命令时 IDE 会扩展 $FileNameWithoutExtension$
。
我正在过渡到使用 Vim。我是 Vim n00b。
我如何使用 Vim(特别是 MacVim)做同样的事情?
In my IDE (webstorm) I have configured an external tool to run ant like so:
ant myTarget -DfileNoExt="$FileNameWithoutExtension$"
the $FileNameWithoutExtension$
is expanded by the IDE when the command is run.
I am transitioning to using Vim. I am a Vim n00b.
How do I do the same with Vim (MacVim specifically)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Vim 会将
%
扩展为当前文件。您可以对其使用修饰符(请参阅:help filename-modifiers
)。您可以告诉 vim 使用 ant 作为您的 make 程序:现在您可以使用
:make
来构建当前文件。您应该在快速修复中遇到构建错误(使用:copen
查看)。您可能希望将上述脚本放入文件
~/.vim/after/ftplugin/java.vim
中。这将为您打开的每个 java 文件加载它。请注意,如果您想使用不同的目标,
:make
会将所有参数传递给 ant。因此:make otherTarget
将执行ant myTarget -DfileNoExt="file" otherTarget
。Vim will expand
%
as the current file. You can use modifiers on it (see:help filename-modifiers
). You can tell vim to use ant as your make program:Now you can use
:make
to build your current file. You should get build errors in your quickfix (view it with:copen
).You probably want to put the above script into a file
~/.vim/after/ftplugin/java.vim
. That will load it for every java file you open.Note that if you want to use different targets,
:make
will pass all arguments to ant. So:make otherTarget
will executeant myTarget -DfileNoExt="file" otherTarget
.你可以在 vim.rc 中映射热键或你自己的按键序列(在 mac 中不确定,应该有类似的资源文件)
将此行添加到你的 vim 资源文件中:
这意味着当你编辑源代码时,按 F5 将运行你的蚂蚁工具
有关更多信息,您可以阅读 http://vim.wikia.com/wiki/Compile_Java_with_Sun_JDK_javac 和 < a href="http://www.vim.org/scripts/script.php?script_id=155" rel="nofollow">http://www.vim.org/scripts/script.php?script_id=155
you can map either Hotkey or Your own key-sequence in vim.rc(not sure in mac, should have similar resource file)
add this line to your vim resource file:
which means when you editing the source code, press F5 will run your ant tool
for more, you can read http://vim.wikia.com/wiki/Compile_Java_with_Sun_JDK_javac and http://www.vim.org/scripts/script.php?script_id=155