How do I successfully use VIM as an external editor for Code::Blocks?


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:

  1. 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?

  2. 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

9/12/2009 3:06:08 PM

  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.

9/13/2009 2:42:56 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow