12

I would like to have another pane active when debugging a Vimscript function which would show the values of chosen local variables and function arguments dynamically.

Currently I have to echo or let to see variable values. It would be more convenient to have them display automatically.

Is there a way to do this without a plugin? Is there an easy way to script this with, say, an autocommand for example?

2 Answers 2

7

Vim :debug sessions are modal. When started we are prisoner of this non ergonomic mode. We could try to send anything we want to a buffer or a window, that window will never get refreshed and properly displayed. I guess Vim core would need to be multithreaded to support this, which is not the case. This _issue_ was quickly mentioned during a poll on what plugin authors would need.

There is no native way to watch variables while debugging a vim script. There exist plugins though. I'm aware of https://github.com/albfan/vim-breakpts -- which, IIRC, runs another vim session where the script being debugged is actually ran.

Because of the poor native user interface of :debug I do my best to avoid loops (I use map(), filter()... instead), and I often try to avoid debugging and instead play with with a few frameworks I'm maintaining:

Since my initial answer, I've documented my take regarding debugging in my plugins.

4

Even in v8.1, the short answer is no; you cannot positional-statically display the content of a variable without a plugin ... OR additional vim scripting.

Alternatively

However, Decho plugin does allow you to write info into another screen/buffer in a live manner using function calls.

And DBGp is a debugger GUI for Vim debugging session (written in Python and Vimscript) also will write variable values to another "window" pane (or grid box) in a static cursor positional manner.

Both of which you could extract certain Vim script codings that deals with placing variable values in another actively-displayed buffer, in which you could put these snippet of codes into your local ~/.vimrc and that would be the solution for your 'plugin-less' approach.

References

  • Decho (by Dr.Chip) or
  • or this updated Vim debugger (DBGp) plugin in Github.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.