0

I'm wondering if it's possible to do a search and replace in Sublime Text 3 to add spaces around brackets in multiple files.

For example, I need to convert this in multiple files:

$var = function($par1, $par2);

to:

$var = function( $par1, $par2 );

Any ideas? If so, how can I do it?

Thanks in advance

leemon
  • 917
  • 4
  • 19
  • 47

1 Answers1

0

After some fiddling around, I managed to come up with a regex to add spaces around brackets:

Find: \((.*?)\)
Replace: ( $1 )

UPDATE: The following regex is more precise because it matches ($var) but not ( $var ) nor ():

Find: \((?!\s)([^()]+)(?<!\s)\)
Replace: ( $1 )
leemon
  • 917
  • 4
  • 19
  • 47