Debugging With yasnippet

Bin Chen has an excellent post on adding debug statements into source code using yasnippet. Us old timers are used to adding printf statements into our code to create an audit trail of the execution. There are, of course, modern tools that obviate the need for these statements but sometimes they’re just what you need to do a quick check. The nice thing is that the strategy works with any language.

Chen’s idea is to leverage yasnippet to insert the debug statements with as little effort as possible. His post uses javascript as the example language but, as he remarks, the same idea works for any language. It’s easy to underestimate how flexible yasnippet can be. The examples that Chen gives shows how it can extract a lot of information from the source code. This makes it possible to insert an entire debugging statement with a minimum of input. See Chen’s post for examples of this.

Even if you’re not interested in debugging, Chen’s post will give you some ideas about using yasnippet in non-trivial ways. I highly recommend his post.

This entry was posted in Programming and tagged . Bookmark the permalink.