Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m looking for a software development tool that will allow me to rewrite small

ID: 661533 • Letter: I

Question

I'm looking for a software development tool that will allow me to rewrite small pieces of code.

For example, if I have the following code:

quux(foo(abc), bar(xyz))

and would like to rewrite it as:

var f = foo(a)
var b = bar(xyz)
quux(f, b)

The tool will allow me to write a small regular expression to match the parts of the first quux call and rewrite it as the second. I have to repeat this process many times in several files. I would like to select each occurrence and tell the tool to process it. The tool should also allow me to save the replacement patterns.

The tool does not have to have full "re-factoring" ability, nor does it have to understand the syntax or semantics of the code. It should just treat the code as text to be edited.

Ideally, the tool will be a plugin for IntelliJ, Eclipse, or Sublime Text 2. FOSS is best, but a small, reasonable price is also acceptable.

Explanation / Answer

Eclipse and IntelliJ both have a built-in template feature that does what you want. You enter a small bit of text and then hit tab (or whatever the bind button is) and it expands into the longer text and then you just fill in the details.

For example in IntelliJ I can type fori and hit tab and it produces

for(int i = 0; i < ; i++) {

}

I can fill in the end condition and the body and move on. Since it's just text replacement, it doesn't matter what language you're working in. You could create one that replaces fs with the entire Gettysburg Address if you want.

You can see what's available and create your own by going to File > Settings > IDE Settings > Live Templates.

I did a test with your example and it looks like it doesn't like spaces and punctuation in the abbreviation so I tried the following:

Abbreviation: quux

var f =
var b =
quux(f, b);

It's a little different from what you had but you don't have to type as many characters this way.

I don't use this feature very often but I know others who do and they say that it saves them time and in the case of team efforts helps make sure everyone is doing things the same way.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote