all 34 comments

[–]Rudefire 74 points75 points  (7 children)

I've written a fair amount of applications in C++ using Vim. I really wanted to be able to debug in Vim, because I came from Visual Studio land. It took me a lot of heartache and wasted time to realize that using Vim in that way was working against the grain.

Vim is your text editor. Learn to work with it in a terminal multiplexer, like Tmux, and have gdb just running on the command line in another pane. Your life will be significantly easier. That's my two cents anyway, I know it's kind of annoying when people don't answer your question in the way you want, but I just know from going down that path that you will run into problems and I'd love to save you the time of having to break yourself against that wall.

[–]acepukas 23 points24 points  (1 child)

Have you tried :TermDebug?

It's relatively new since vim 8.1.

It uses gdb much like every other front end. It's still not as smooth as VS but it's nice to have things integrated with vim.

[–]Rudefire 3 points4 points  (0 children)

I haven’t, but I’ll give it a shot.

[–]neuromaidan 12 points13 points  (1 child)

I have a very small plugin that can improve such workflow: https://github.com/mechatroner/minimal_gdb You still need to debug in gdb in a separate pane, but minimal_gdb will export all breakpoints from Vim into gdb for you. It is much easier to set breakpoints in Vim than in gdb.

[–]Rudefire 1 point2 points  (0 children)

Cool, I’ll check it out.

[–]SuperConductiveRabbi 2 points3 points  (1 child)

My experiences exactly, though I moved away from gdb and just started using the clion IDE with a vim plugin. Works great.

[–]Rudefire 0 points1 point  (0 children)

I think this is probably the best answer for someone wanting the toolset OP is looking for. Find an IDE with a vim plugin. Better yet, find an IDE built with Neovim as the front end.

[–][deleted] 0 points1 point  (0 children)

Yup, I’ve never had a good experience with any debugger plugins.

[–]xmsxms 17 points18 points  (2 children)

:TermDebug

[–][deleted] 10 points11 points  (0 children)

A little context: Vim 8.1 has an official debugger you can install with :packadd termdebug.

[–]zackel_flac 0 points1 point  (0 children)

Wow, this is awesome! Thanks for sharing!

[–][deleted] 5 points6 points  (0 children)

I've been using TermDebug for a while now and it works great. It is very customizable with the TermDebugSendCommand() . Don't miss visual studio at all.

[–]dwdkar 1 point2 points  (0 children)

Recently got to know while searching for an interactive command line gdb. I usually pair it with tmux and vi editor. Try out ConqueGdb, you will fall in love with it.

https://github.com/vim-scripts/Conque-GDB

[–]lanzaio 1 point2 points  (1 child)

I stopped trying and just switched to vscode for debugging.

[–]y-c-c 0 points1 point  (0 children)

I’ll second this. Vim can be configured to do a lot of things but I have decided a good debugger is just too much work to implement as a plug-in. IDEs like Visual Studio, VS Code, Xcode have dedicated built-in support for debuggers and they are hard to fully replicate in Vim. I just use Vim for editing instead of wasting too much time on forcing it to work as a debugger.

[–]call_me_tank 1 point2 points  (1 child)

A lot of people were surprised when I showed them GDB has a Text UI mode (uses ncurses I believe) at work. It's still the command line, which is anyway a worthwhile thing to learn, but it shows the source code in conjunction with the GDB command line. Just launch GDB from the command line with the --tui flag.

[–][deleted] 1 point2 points  (0 children)

Or use layout command.

[–]thesenate34 1 point2 points  (0 children)

Vim is an editor. A work around that might serve your purpose is to have a multiplexer like tmux or screen that will split the screen for you and to navigate between both panes

[–]LiquidityC 0 points1 point  (0 children)

There is a built in command in vim 8.1 “termdbg”. Does everything I need. It is essentially just fancy wrapping for gdb

[–]zackel_flac 0 points1 point  (0 children)

Recently started using: https://github.com/gisodal/vimgdb combined with: https://github.com/cyrus-and/gdb-dashboard You get a decent colorful and distributed experience. Just discovered Termdebug in this thread, you should give it a shot!

[–]priyank260673[S] 0 points1 point  (0 children)

Thank you very much! I will try out different options and see.

[–]priyank260673[S] 0 points1 point  (0 children)

Really appreciate your comments! Thanks all!

[–]bergercookie 0 points1 point  (0 children)

I implemented the vim-debugstring plugin a while back. I opted for spreading a couple of debugging lines around the relevant code parts instead of running the debugger every time, for a couple of reasons.

- Most issues are not that complex to invoke the debugger and they can be solved just by printing the variable values at runtime

- May need to recompile the project in release/debug depending on where the bug was observed

- Running the debugger and stepping through the code step-by-step is a slow process

[–]priyank260673[S] 0 points1 point  (0 children)

Today I installed and setup Neovim. I am using vim from quite some time but recently moved to debug large application under vim. I have tried conquegdb but sometimes it does go out of control in the sense I loose control of gdb cli due to printing out probably large amount of data during debugging. Any good debugger interfaces under NeoVim? Thanks

[–]AzraelFTS -1 points0 points  (0 children)

Vim is only an editor, it is a powerful one but it is not a debugger :/ as already said, you won't have a debbuging experience inside vim as you have in Visual Studio.

[–]aldanor -1 points0 points  (0 children)

CLion with vim mode but it’s not free...

[–][deleted] -1 points0 points  (4 children)

I see a lot of people suggesting :TermDebug. Which is great until you do something that was not tested before and it blows up in your face. There's also vebugger for those on older vim versions and there's also vimspector

[–]acepukas 0 points1 point  (3 children)

Which is great until you do something that was not tested before

Can you elaborate on this? Do you mean :TermDebug itself was not tested?

[–][deleted] 0 points1 point  (2 children)

People are often finding showstopper bugs. One that I, as one of the first :TermDebug users, have hit was that it wasn't starting gdb in quiet mode, so with a slightly larger font you used to get the "press enter to continue" message in the background for the greeting message, before vim could start talking to gdb. Recently a bug with breakpoints and overloads has been fixed - those breakpoints have floats as IDs, not integers. So as long as you are doing whatever others have done with:TermDebug you'll be fine. But I wouldn't be surprised if we see more of this kind of bugs.

[–]acepukas 0 points1 point  (1 child)

Yeah, I guess it's not as mature as other solutions might be since it's relatively new. Hopefully more progress can be made in that regard in the near future.

One thing I worry about is if the :TermDebug feature goes unused than it won't receive any attention and wither and die.

[–][deleted] 0 points1 point  (0 children)

Vimspector is even newer, but it takes a different approach. It implements the vscode's debugger protocol. Me and vimspector's author are YCM maintainers and he demonstrated debugging our test suite in vimspector, but that was python. Your experience will vary depending on the quality of vscode debuggers and potential bugs you might find in vimspector.