Tuesday, 31 January 2012

Quick evaluation of complex properties in Xdebug within Vim

For those of us who still use Vim for PHP development, getting Xdebug to work nicely with complex properties is a pain. Most of the time we end up evaluating print_r to get any sort of complex structure or deeply nested value. Not any more! Use this remapping:

nnoremap ,p :python debugger_watch_input("property_get")<cr>A
This is similar to ,e for quick evaluation, but lets you quickly get any given property. Press ,p and type the property you want or, if you prefer, use yank and ^R to copy/paste the property into the debugger window. It works for objects and array subscripts, so you can type complicated things like:

/*}}}1*/ => property_get: $this->someArray['mySubscript']
and get the value of the named property.

No comments:

Post a Comment