6

I'm interested in different ways to debug/trace or/and see the execution in real time (a la bash -x) vimscript.

1
  • 5
    start reading at :h debug-scripts Commented Sep 10, 2020 at 7:22

1 Answer 1

7

In an extremely related Q/A, I've listed all the tools I provide and use to help tracking errors in vim scripts: https://vi.stackexchange.com/a/25863/626

They complement :debug.

6
  • Very nice! One question though: you mentioned on your post that :debug isn't perfect, and would be better if Vim was multi-threaded...but doesn't Vim have async support now? Can :debug profit from it? Commented Sep 10, 2020 at 9:01
  • 2
    Unfortunately no. I don't know the specifics. Somehow, Vim async implementation is equivalent to processes in the background with asynchronous communication. Vim kernel isn't multithreaded. I don't know whether it's done with polling or interruptions when something is received. What I observe is that when a message is received, normal processing is interrupted the time the message is being handled, then resumed. Commented Sep 10, 2020 at 9:21
  • Gotcha! That's very informative. Hopefully we'll see a real hyper-threaded support in the near future. Commented Sep 10, 2020 at 9:23
  • 1
    That's unlikely :( Commented Sep 10, 2020 at 9:26
  • UI thread is necessarily single threaded anyway, and the majority of Vim plugins and functions are constantly working on the UI, either capturing input or changing the screen. Multithreading UI makes writing code and plugins much harder to get right, and is not going to be faster since you'll have to take lots of fine grained locks, which will actually slow things down. The only thing you can multithread are generally computationally heavy tasks that doesn't involve much UI interaction and for those, you can just use message passing, aka async communications to a separate process just fine.
    – Lie Ryan
    Commented Sep 12, 2020 at 4:44

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.