如何成功地将VIM作为Code::Blocks的外部编辑器使用?

8

我非常喜欢Code::Blocks的构建系统和逐步调试功能 - 也就是说,我更喜欢使用gcc/gdb的包装器而不是使用Makefiles或命令行。问题是,经过多年的VIM使用,我已经对标准Windows文本编辑器无法编辑了。

所以,我设置了Code::Blocks使用VIM作为.cpp/.c/*.h的文件处理程序,并配合VIM的--server-name和--remote-tab选项,可以右键单击C::B项目窗口中的文件并选择使用文件扩展名处理程序打开它们,它们会在一个单独的VIM窗口中弹出新的选项卡 - 然后我切换回C::B,按F9进行构建和运行等操作。

我想改进我的工作流程,因此问题有两个方面:

  1. 当我双击项目文件列表中的文件时,能否使C::B默认打开VIM,而不是必须右键单击->使用文件扩展名处理程序打开?

  2. 我能否在VIM中绑定一些按键,使Code::Blocks构建/运行/调试我的项目?

关于第二个问题,我知道C::B有重建项目的命令行选项,但这与打开C::B窗口并查看编译日志/监视窗口并不相同。我还注意到C::B有一个非常基本的DDE接口 - 我可以使用VIM发送DDE命令吗?也许有一个简单的SendKeys插件,我还没有找到可以修改工作的?

或者,是否有像C::B这样轻巧且最小化的IDE,使使用外部编辑器变得非常容易?我不准备运行Eclipse,并且在Visual Studio中使用Microsoft的编译器让我感到恶心。

任何帮助都将不胜感激。

谢谢,Johan


我遇到了同样的问题。我只使用Code Blocks进行调试/调用堆栈/监视变量等目的。如果Vim有这些功能的插件,那将是不可思议的。 - JohnJohn
1个回答

3
  1. After digging about, I have to conclude that the answer is no. The Open option is meant to open within C::B only.
  2. 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 invoke make 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
    

    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.


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接