Tuesday, November 5, 2013

Programmer's Diary: Extract Variable NetBeans Macro

This is a repost from my old blog. Original post date June 14, 2013

I've got tired of manually extracting local variables so I wrote a little macro to do the job for me. Just copy-paste it into a new NetBeans macro, and add a shortcut to it.

Then, select the code you want to put into a variable, hit your shortcut and watch the magic happen.

---

cut-to-clipboard
split-line
caret-up caret-end-line insert-break
"$newVariable = " paste-from-clipboard ";"
caret-down caret-end-line "$newVariable"
caret-down caret-begin-line
selection-begin-line rem


---