views:

261

answers:

6

The question is to all you people, who use VIM to develop C++ apps.

There was a period in my life, which can be described as 'I hate VIM!!!'..'VIM is nice!' However, having grown up mostly on MS Dev IDE, I've got used to those F5-F11 shortcuts when debugging code, watch window, call stack and the main code - all visible vithout need to type any gdb commands.

So, here is the question: Do you use VIM as well for debugging ? Or you switch to some IDE for this purpose ? Which one ? For those who use VIM to debug code: are there plugins to set breakpoints in editor, highlight the line we're currently debugging, auto-navigation during step, step into, step out ?

Please, don't tell me you use gdb as command line, see only one line which is debugged etc.

And thanks for all your answers. Andrey

A: 

Having just recently worked on an application for a long time that required a bunch of stuff to be in place on the box it was running (appliance set up), I wrote code in vim, had scripts which automated building, pushing it to a server, which had a script there to notice the sentinel file pushed along with the binaries. This would then restart the appropriate services on the box, and in another ssh window I had a tail -f running on my log file.

Long story short, I didn't use a debugger at all. If I had something die unexpectedly, I'd just bump up logging levels, redo it, and see what was the last thing logged before it died, then analyze that and fix the issue.

The nice thing was that when something had problems in a customer environment, I'd just ask for a Debug-level log and could identify the issue without even requiring access to their server.

... but yes, there were times when it would have been nice to have a debugger.

Shawn D.
+6  A: 

vim is a nice editor, but to do debugging I use a debugger (like gdb).

But you don't have to use gdb in text mode, you can use a graphical frontend like kdbg, ddd or insight.

There are ways of getting gdb into vim (but then you do get text based debugging).

Johan
Try gdbtui.. terminal based but quite effective..
Jack
gdbtui is also nice.
Johan
A: 

I use Eclipse for C (its just the best IDE for C), but it lags in C++. I will be using QtCreator during my lectures this semester, it looks very solid (even if you are not using Qt).

I use vim only for fast and small modifications in code. Once I need to traverse the code more I always switch to some IDE (fast code navigation is definitely something that editors lack).

Let_Me_Be
ctrl-] jump to the definition of a method/class, gd - go to definition, gf - open file contained in the string that the cursor is over. If you add one of the numerous fuzzy finder plugins out there, and you get better project navigation then most IDEs
Matt Briggs
@Matt Eclipse has callgraphs for data structures, that is something that I didn't see anywhere else yet. Callgraphs in general is something that allows you super fast code traversal (very hard to include into vim).
Let_Me_Be
A: 

I use vim + ctags + taglist for writing and browsing code on Windows and *nix systems. As far as I know there is no way to use a debugger from within vim, so I use external debuggers (VS, windbg, gdb...).

Nemanja Trifunovic
+5  A: 

In contrast with the other answers, there are at least three options that do just what you require: clewn, pyclewn and vimgdb.

All three projects are related. vimgdb is a patch against Vim and requires Vim to be recompiled. clewn is a standalone program that communicates with Vim through the Netbeans socket interface. This requires Vim to be built with the +netbeans option (this is the case in recent Linux distributions so it shouldn't be a problem).

To quote from the clewn's website:

Clewn implements full gdb support in the vim editor: breakpoints, watch variables, gdb command completion, assembly windows, etc.

I think you should definitely give it a go.

The homepage of the pyclewn website shows a comparison between the three projects.

A few months ago I tried pyclewn. It was a bit difficult to set up, but it looks well though out and promising. I just did some tests and you could set bookmarks, etc., the usual stuff you would expect from a graphical debugger. I ended up not using it for contingent reasons but I am keen to give it another try.

UncleZeiv
+1  A: 

Using a source level debugger is only one of many ways to diagnose faulty program behavior, and I rarely find myself launching one -- despite the fact that it is very easy to do.

So for me, there is simply no inherent advantage to using a text editor that happens to also be a debugger. Instead, I use the text editor that I prefer -- independent of what debugger I choose to use. At the moment, I mostly use gedit and kdbg for these purposes, but these choices evolve independently over time.

nobar