[TxMt] Regex to indent new lines between tags

Ian Smith-Dahl isd at strangetower.com
Mon Jun 11 01:50:37 UTC 2007


On Jun 10, 2007, at 2:31 PM, Mike Stickel wrote:

>
> I'm going through multiple updates on a very large site. There is  
> already a series of search and replaces that I'm doing on these  
> files. In order to format the existing code a little better I was  
> hoping I could just use another search and replace instead of  
> selecting the code and using the indent command.

If your html head is relatively simple you may be able to do it with  
negative matches on your regexp.

For example, if you have:

<html>
<head>
<title>
<meta ... >
<style ...>
</head>
<body>

...

</body>
</html>


You could replace all newlines that *don't* start with those 9 strings

I'm not sure I have the syntax right here, but something along these  
lines:

find: ^^[</{0,1}html>|</{0,1}head>|<title>|<meta|<style|</{0,1}body>] 
(.*)
replace: \t$1



More information about the textmate mailing list