Debugging Vim scripts
Sometimes things in your scripts do not work exactly as you expect them to. In these cases, it is always good to know how to debug your script.
In this section, we will look at some of the methods you can use to find your error.
Well-structured code often has fewer bugs and is also easier to debug.
In Vim, there is a special mode to perform script debugging. Depending on what you want to debug, there are some different ways to start this mode. So let's look at some different cases.
If Vim just throws some errors (by printing them at the bottom of the Vim window), but you are not really sure where it is or why it happens, then you might want to try to start Vim directly in debugging mode. This is done on the command line by ...