如何成功使用VIM作为Code :: Blocks的外部编辑器? [英] How do I successfully use VIM as an external editor for Code::Blocks?
问题描述
我非常喜欢Code :: Blocks作为其构建系统并逐步调试功能 - 即我非常喜欢使用封装到gcc / gdb而不是使用Makefile或命令行。问题是,经过多年的VIM使用,我已经大脑损坏了(或者有些人可能会说,而且我无法在标准的Windows文本编辑器中
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.
因此,我设置Code :: Blocks以使用VIM作为 .cpp / .c / * .h的文件处理程序,以及VIM的--server-name和 - remote-tab选项可以右键单击我的C :: B项目窗口中的文件,然后选择用文件扩展名处理程序打开它们,它们在单个VIM窗口中弹出为新选项卡 - 然后我切换回C :: B,点击F9进行构建和运行等。
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:
-
当我双击项目的
文件列表中的文件而不必右键单击 - >时,我可以默认使C :: B打开VIM吗?打开文件扩展名处理程序?
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?
我可以在VIM中做一些绑定,让我点击一个按钮,让Code :: Blocks
构建/运行/调试我的项目?
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,我知道C :: B有重建项目的命令行选项,但这不一样打开C :: B窗口并查看编译日志/监视窗口。我还注意到C :: B有一个非常基本的DDE接口 - 我可以使用VIM发送DDE命令吗?也许有一个简单的SendKeys插件,我还没有发现我可以破解工作?
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?
或者,有一个像C :: B这样的轻量级IDE使用外部编辑器真的很容易吗?我不准备运行Eclipse,并且在Visual Studio中使用Microsoft的编译器让我感到窒息。
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.
任何帮助表示赞赏。
谢谢,
Johan
Thanks, Johan
推荐答案
- 在挖掘之后,我必须得出结论答案是否定的。 Open选项只能在C :: B中打开。
-
Vim支持使用内置命令构建项目。如果你有C :: B生成你的
Makefile
(它应该是 - 我从来没有达到我想要的方式),然后确保Vim的工作目录(:cd
),然后你只需输入:make
和Vim,默认情况下会调用make
在当前目录中。您可以:set makeprg
运行您需要的任何脚本,包括运行任何配置脚本。我还将此添加到我的.vimrc
:
- After digging about, I have to conclude that the answer is no. The Open option is meant to open within C::B only.
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
:
:map <F8> :make<CR>
:imap <F8> <Esc>:make<CR>a
:vmap <F8> <Esc>:make<CR>a
它适合我的目的,因为:make
还将GCC输出中的错误和警告放入检查窗口。 :cn
导航到包含下一个错误的文件。
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.
这篇关于如何成功使用VIM作为Code :: Blocks的外部编辑器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!