For a project I'm working one I'm trying to figure out a way to tab indent new lines of code between certain tags (mainly <head> and <body>). Unfortunately I'm not as good at regular expressions as I thought I was and can't figure it out.
Anyone out there able to lend a hand?
Thanks,
Mike Stickel http://screenflicker.com/mike/ | http://gonecksgo.com
On 9. Jun 2007, at 20:26, Mike Stickel wrote:
For a project I'm working one I'm trying to figure out a way to tab indent new lines of code between certain tags (mainly <head> and
<body>). Unfortunately I'm not as good at regular expressions as I thought I was and can't figure it out.
Anyone out there able to lend a hand?
Exactly when do you want what to happen?
If you have the following:
<head> bla bla </head>
<body> bla bla </body>
Then select it and use Text → Indent Selection (⌥⌘[]) then you get:
<head> bla bla </head>
<body> bla bla </body>
Is this the functionality you are after?
On Jun 10, 2007, at 1:57 AM, Allan Odgaard wrote:
For a project I'm working one I'm trying to figure out a way to tab indent new lines of code between certain tags (mainly <head> and <body>). Unfortunately I'm not as good at regular expressions as I thought I was and can't figure it out.
Anyone out there able to lend a hand?
Exactly when do you want what to happen?
If you have the following:
<head> bla bla </head> <body> bla bla </body>
Then select it and use Text → Indent Selection (⌥⌘[]) then you get:
<head> bla bla </head> <body> bla bla </body>
Is this the functionality you are after?
That's what I have been doing but I was wondering if there was a way to do it with the search and replace dialog using regular expressions to replace all the \n with \n\t to get that indent
Mike Stickel http://screenflicker.com/mike/ | http://gonecksgo.com
On 10. Jun 2007, at 18:04, Mike Stickel wrote:
[...] That's what I have been doing but I was wondering if there was a way to do it with the search and replace dialog using regular expressions to replace all the \n with \n\t to get that indent
So you want to re-indent your HTML solely by running a single regexp replace?
This is not possible -- why is that restraint necessary?
[...] That's what I have been doing but I was wondering if there was a way to do it with the search and replace dialog using regular expressions to replace all the \n with \n\t to get that indent
So you want to re-indent your HTML solely by running a single regexp replace?
This is not possible -- why is that restraint necessary?
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 there's no way to do it then it's no big deal, I was just curious.
Mike Stickel http://screenflicker.com/mike/ | http://gonecksgo.com
On 10 Jun 2007, at 19:31, Mike Stickel wrote:
[...] That's what I have been doing but I was wondering if there was a way to do it with the search and replace dialog using regular expressions to replace all the \n with \n\t to get that indent
So you want to re-indent your HTML solely by running a single regexp replace?
This is not possible -- why is that restraint necessary?
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 there's no way to do it then it's no big deal, I was just curious.
Maybe use Tidy and a bash script
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