4

I would like to dynamically debug a vim script. My current workflow is that I have the autoload plugin opened on a tmux pannel and the running application on the other pannel. I also set a tail -f vim.log and I launched vim with vim -V15vim.log. My goal is to monitor the execution of the plugin by adding plenty of echom.

Actually I was expecting something more useful that what I actually got.

  • I need to restart vim everytime I add a new echom
  • Nothing really useful is displayed on the log file vim.log
  • This method is obviously not the right one

I also tried to add breakpoints with breakadd func myfunc#test but it is not really working because the debugger windows interfers with the main window and change the way the plugin I am debuging behave.

How to improve my vim-script debug workflow?

HINT

I am actually trying to debug the vim-multiple-cursor plugin which does not work with a column block selection and virtualedit enabled. I would like to fix it.

nowox
  • 25,978
  • 39
  • 143
  • 293
  • See also: [Debugging Vim plugins with call traces - Stack Overflow](https://stackoverflow.com/questions/9656429/debugging-vim-plugins-with-call-traces#comments-9668599) – user202729 Oct 08 '21 at 09:48

1 Answers1

2

:breakadd is the most powerful tool, but yes, its output and interaction may interfere with certain plugin actions, and trigger additional autocmds. It may help if you specify the optional [lnum] offset to only stop executing inside the function.

I need to restart vim everytime I add a new echom

It should be enough if you just :source the changed plugin script again. Scripts inside ~/.vim/plugin/ usually employ a multiple inclusion guard that you need to work around, though. My ReloadScript plugin can help with that.

Alternatively, the Decho plugin might offer a different approach worth looking at.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324