如何成功使用 VIM 作为 Code::Blocks 的外部编辑器?
我真的很喜欢 Code::Blocks 的构建系统和单步调试能力 - 也就是说,我真的很喜欢使用 gcc/gdb 的包装器,而不是从 Makefile 或命令行使用它们。问题是,由于多年使用 VIM,我的大脑受到了严重损伤(有些人可能会说被宠坏了),以至于我无法在标准 Windows 文本编辑器中进行编辑。
因此,我设置 Code::Blocks 使用 VIM 作为 .cpp/.c/*.h 的文件处理程序,并与 VIM 的 --server-name 和 --remote-tab 选项一起使用- 单击我的 C::B 项目窗口中的文件,然后选择使用文件扩展名处理程序打开它们,它们会在单个 VIM 窗口中作为新选项卡弹出 - 然后我切换回 C::B,按 F9 构建并运行 我想改进我的工作流程,所以
问题有两个:
当我双击项目中的文件时,我可以让 C::B 默认打开 VIM 文件列表,而不必右键单击 ->使用文件扩展名处理程序打开?
我可以在 VIM 中进行一些绑定吗,这样我可以点击按钮并获得 Code::Blocks 构建/运行/调试我的项目?
WRT 2,我知道 C::B 有用于重建项目的命令行选项,但这与打开 C::B 窗口并查看编译日志/监视窗口不同。我还注意到 C::B 有一个非常基本的 DDE 接口 - 我可以使用 VIM 发送 DDE 命令吗?也许我还没有找到一个简单的 SendKeys 插件,我可以破解它来工作?
或者,是否有像 C::B 这样的轻量且最小的 IDE 可以让使用外部编辑器变得非常容易?我还没有准备好运行 Eclipse,并且在 Visual Studio 中使用 Microsoft 的编译器让我感到恶心。
任何帮助表示赞赏。
谢谢, 约翰
I really like Code::Blocks for its build system and step through debugging abilities - ie I really enjoy using wrappers to gcc/gdb more than using them from Makefiles or the command line. The problem is, I'm so brain damaged (or spoilt, some might say) by years of VIM use that I cannot edit in a standard Windows text editor.
So, I setup Code::Blocks to use VIM as the file handler for .cpp/.c/*.h and along with VIM's --server-name and --remote-tab options can right-click files in my C::B project window and select to open them with the file extension handler and they pop up as new tabs in a single VIM window - then I switch back to C::B, hit F9 to build and run etc.
I would like to improve my workflow, so the question is two-fold:
Can I make C::B open VIM by default when I double-click a file in the project's
file list instead of having to right-click -> open with file extension handler?Can I do some binding in VIM that would allow me to hit a button and have Code::Blocks
build/run/debug my project?
WRT 2, I know C::B has command line options for rebuilding a project, but that's not the same as having a C::B window open and seeing the compile log / watch windows. I also note that C::B has a very basic DDE interface - can I use VIM to send DDE commands? Perhaps there's a simple SendKeys plugin I haven't found yet that I could hack to work?
Alternatively, is there a light and minimal IDE like C::B that makes using an external editor really easy? I am not prepared to run Eclipse, and using Microsoft's compilers in Visual Studio makes me gag.
Any help appreciated.
Thanks,
Johan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Vim 支持使用内置命令构建项目。如果你已经让 C::B 生成了
Makefile
(它应该是这样 - 我从来没有按照我想要的方式得到它),那么请确保 Vim 的工作目录 (:cd),然后你只需输入
:make
,Vim 默认会在当前目录中调用make
。您可以:set makeprg
来运行您需要的任何脚本,包括运行任何配置脚本。我还将其添加到我的.vimrc
中:它非常适合我的目的,因为
:make
还将 GCC 输出中的错误和警告放入检查窗口。:cn
导航到包含下一个错误的文件。Vim supports building projects using built-in commands. If you've got C::B generating your
Makefile
(which it should be - I never got it to the way I wanted), then make sure Vim's working directory (:cd
), then you can simply type:make
and Vim, by default will invokemake
in the current directory. You can:set makeprg
to run whatever script you need it to, including running any configure scripts. I also added this to my.vimrc
:It works pretty well for my purposes, as
:make
also puts errors and warnings from GCC's output into the check window.:cn
navigates to the file containing the next error.