Sunday, February 19, 2012

if-ify, for-ify, foreach-ify and func-ify

A common question among developers is how to surround the current selection in the editor with a parent statement. For example if you start coding a statement that validates an expression and then want to iterate over an array of expressions and do the same to all its elements.

For this end Eclipse templates provide two variables "line_selection" and "word_selection" that help you build custom selection-based wrappers.

In this example three new templates were added to simplify this scenario:



You can import these templates (xml below) to your IDE via Preferences > PHP > Editor > Templates > Import...

2 comments:

wimjongman said...

Cool Ray. Thank you for this info.

wimjongman said...

Roy! D@mn autocorrect.