0

From time to time, I find myself using the same group of statements and I would like to convert these statements into function. Are there ways, steps, procedure, or tools that will help me / aid me to do so?

When I develop in VS2008 in C#, I'll simply highlight a group of statements, and tell VS to automatically convert these into a method.

Again, if there are no tool, a procedure will do.

UPDATE

No need to post code. This is base on my experience with developing and refactoring JS code in which I've found a duplicate set of codes, but I was wary from changing the code since I might break the code.

search and replace is useful when you want to replace a set of common expression with a variable, something like replacing $(this) to $this.

OnesimusUnbound
  • 2,886
  • 3
  • 30
  • 40
  • can you give an example of code? – Austin Jul 06 '12 at 14:55
  • A similar question has already been answered here: http://stackoverflow.com/questions/1446267/how-do-you-refactor-javascript-html-css-etc – Vala Jul 06 '12 at 14:57
  • 1
    i dont know if thats what you're looking for, but e.g. Aptana Studio supports Find/Replace with Regular Expressions, so that should do it.. – androidavid Jul 06 '12 at 14:58

1 Answers1

1

PHPStorm has a 'refactor to method' function (CMD-ALT-M on OSX), which does this.

Matt Gibson
  • 14,616
  • 7
  • 47
  • 79
  • Thanks @Matt Gibson, this is very close to what I'm looking for. I'm currently trying to check to tool out. I'll let you know if this answers my question. – OnesimusUnbound Jul 06 '12 at 15:25