I'm trying to create a vim command to easily insert a debug statement on the variable name under the cursor. I would at least like to handle some common cases so it doesn't have to be perfect but the following should all work:
$test_var = array($test->get_test_var()) || $test->get_test_var() || $test_var;
Having the cursor over any of these variable names and running the command should insert a line above the call with the value of the expression inside. E.g. place the cursor over anything in '$test->get_test_var()' and then the following is inserted above on a new line:
print_r($test->get_test_var());
Placing the cursor over 'array($test->get_test_var())' should insert the same thing and not include the array. Placing it over array should do this:
print_r(array($test->get_test_var()));
And finally, placing it over '$test_var;' should insert the following (not including the semicolon):
print_r($test_var);
Obviously I'm working on this myself, but some of you could have insight on how to do this easily that I will miss as a relatively new user of vim.