I really like how tabs get nested perfectly just by pressing tab, the start tag that is, the end tag gets on the same line. Is it possible to enhance the behaviour and have the end tag correctly nested one tab stop less? This could also create a wonderful "reformat" macro of sorts to correctly tabulate all HTML and XML files, that would be quite neat.
Andreas
On 26/10/2005, at 18.53, Andreas Wahlin wrote:
I really like how tabs get nested perfectly just by pressing tab, the start tag that is, the end tag gets on the same line. Is it possible to enhance the behaviour and have the end tag correctly nested one tab stop less?
Sort of — there's a decreaseIndentPattern which is currently unset for HTML. If it was set to a close tag, at least TM would know that it should be decreased — currently though, I don't think the tab smart indent uses the decreaseIndentPattern (but it should).
Allan Odgaard wrote:
Sort of — there's a decreaseIndentPattern which is currently unset for HTML. If it was set to a close tag, at least TM would know that it should be decreased — currently though, I don't think the tab smart indent uses the decreaseIndentPattern (but it should).
I ended up defining a snippet that creates the tag on two lines, with proper indentation and then just worked with that.
I've seen the effect of the decreaseIndentPattern in the XML bundle and I don't really like it. Most of the time when I insert something that triggers the decreaseIndent I'm already at the right indent level. Might be because I'm too tidy of a typer and get to the right indent *before* I start typing, instead of letting the editor fix it, but I just couldn't get that behaviour out of my hands and I ended up manually reindenting everytime.
I don't know what others think about this feature, but perhaps some rethinking about this is in order..
Jeroen.
On 26/10/2005, at 23.42, Jeroen van der Ham wrote:
Sort of — there's a decreaseIndentPattern which is currently unset for HTML. If it was set to a close tag, at least TM would know that it should be decreased — currently though, I don't think the tab smart indent uses the decreaseIndentPattern (but it should).
I ended up defining a snippet that creates the tag on two lines, with proper indentation and then just worked with that.
Actually, ctrl-< + return should give the proper indent. i.e. “foo «ctrl-<» «return»” gives:
<foo> | </foo>
I've seen the effect of the decreaseIndentPattern in the XML bundle and I don't really like it.
I don't see any -- is this something you added yourself?
Most of the time when I insert something that triggers the decreaseIndent I'm already at the right indent level.
It should be smart, and only decrease indent when the indent is the same or larger than the line above.
So ... is there a chance it might be set in the future, and will this affect XML as well?
Andreas
Sort of — there's a decreaseIndentPattern which is currently unset for HTML. If it was set to a close tag, at least TM would know that it should be decreased — currently though, I don't think the tab smart indent uses the decreaseIndentPattern (but it should).
On 27/10/2005, at 9.46, Andreas Wahlin wrote:
So ... is there a chance it might be set in the future, and will this affect XML as well?
I actually did this yesterday for HTML, so it'll work in next build. I only set it to the tag names used also with the incr. indent pattern.
I didn't touch XML settings -- I guess it should be set there as well…
It doesen't work the way I want, but it might be hard on the other hand. It works like this [tabs]<p> <p> and if i tab in that last p-tag, it will realign nicely [tabs]<p> [tabs]<p>
however, I usually have
[tabs]<p> [tabs+1]This is my paragraph text <p> and if i tab in that last p it will be aligned with the text, rather than the above p-tag, that is
[tabs]<p> [tabs+1]This is my paragraph text [tabs+1]<p>
rather than
[tabs]<p> [tabs+1]This is my paragraph text [tabs]<p>
is it doable?
Andreas
On Oct 27, 2005, at 12:51 , Allan Odgaard wrote:
On 27/10/2005, at 9.46, Andreas Wahlin wrote:
So ... is there a chance it might be set in the future, and will this affect XML as well?
I actually did this yesterday for HTML, so it'll work in next build. I only set it to the tag names used also with the incr. indent pattern.
I didn't touch XML settings -- I guess it should be set there as well…
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On 28/10/2005, at 11.15, Andreas Wahlin wrote:
It doesen't work the way I want, but it might be hard on the other hand. It works like this [tabs]<p> [...]
is it doable?
Doesn't sound like it, since that would require I parse the document (with a HTML parser) when you press tab.
But Tidy can reformat your document, the Tidy Body Section skips all the boilerplate code (and can work with only a selection.
On 28/10/2005, at 12.23, Allan Odgaard wrote:
On 28/10/2005, at 11.15, Andreas Wahlin wrote:
It doesen't work the way I want, but it might be hard on the other hand. It works like this [tabs]<p> [...]
is it doable?
Doesn't sound like it, since that would require I parse the document (with a HTML parser) when you press tab.
Re-reading your letter, I think I misunderstood you.
The thing you want to do is still problemetaic. You could setup <p> as the indentNextLinePattern, then only the line after the <p> will get indented (thus the <p> below won't), but you probably want several… basically it comes down to, can you express what you want in terms of the 4 indent related patterns?
It might be possible, but I would need to know all your indentation conventions to be able to answer it.
The thing you want to do is still problemetaic. You could setup <p> as the indentNextLinePattern, then only the line after the <p> will get indented (thus the <p> below won't), but you probably want several… basically it comes down to, can you express what you want in terms of the 4 indent related patterns?
It might be possible, but I would need to know all your indentation conventions to be able to answer it.
I think that what I want is, and what seems reasonable to my eyes and ways, is that block-level elements should be alone on a single line,and that all child elements to these should be indented one tab.
<element> [tab]contents which might possibly contain line breaks ... <element>
I actually think that's it. This also applies to all XML-tags that aren't finnished "by themselves" (that is, all <tag></tag>, but not <tag/>)
So perhaps indentNextLinePattern might dot it, it seems to be what I'm after if I understand your explanation.
Andreas
I suggest just taking all the tags from the "meta.tag.block.any.html" scope in HTML language bundle, and then merging them with the increase/decreaseIndentPattern regexp catcher in the HTML preference. Thus creating
decreaseIndentPattern = '^\s*(</(html|head|body|title|table|tr|td| address|blockquote|dd|div|dl|dt|fieldset|form|frame|frameset|h1|h2|h3| h4|h5|h6|iframe|noframes|object|ol|p|ul|applet|center|dir|hr|menu|pre)
|})$';
increaseIndentPattern = '(<(html|head|body|title|table|tr|td|address| blockquote|dd|div|dl|dt|fieldset|form|frame|frameset|h1|h2|h3|h4|h5| h6|iframe|noframes|object|ol|p|ul|applet|center|dir|hr|menu|pre)\b[^>] *>|{)\s*$';
I could of course do this myself, but I'm more comfortable with "official" things, how's that? Now as far as the XML-preference goes, I'm again somewhat regexp stumped.
Andreas
Andreas Wahlin wrote:
<element> [tab]contents which might possibly contain line breaks ... <element>
Thinking about what you want to do, this might work better with a macro that you use at the end of the tabbed contents. This macro would then contain something like: 1. Hit return 2. Decrease indent 3. Insert closing tag.
Just my 2 cents, Jeroen.
Good idea, but not what I have in mind actually. The thing is, when I tab an element, and it moves more than one tab, then I want it backspaced one tab, not otherwise. When the tag tries to auto align, it always goes one set to deep, that's one way to express it. Just try it yourself, I find the behaviour to be extremely wrong, but no one else seems to think so, maybe I'm just mad :)
btw, this makes me thinking, it would be really cool to be able to record things that you do, kinda like a movie, that you can run in textmate and show people what you mean, like this :) probably way to much work for little benefit, but still ...
Andreas
Thinking about what you want to do, this might work better with a macro that you use at the end of the tabbed contents. This macro would then contain something like:
- Hit return
- Decrease indent
- Insert closing tag.
On 29/10/2005, at 9.59, Andreas Wahlin wrote:
Good idea, but not what I have in mind actually. The thing is, when I tab an element, and it moves more than one tab, then I want it backspaced one tab, not otherwise.
Does this work as you want for <div> (amongst others)? i.e. I think the problem is only, that you want indented behavior for more tags than what's setup by default.
btw, this makes me thinking, it would be really cool to be able to record things that you do, kinda like a movie, that you can run in textmate and show people what you mean, like this :) probably way to much work for little benefit, but still ...
And there's also Snapz Pro X or that VNC thingie that can grab movies. You /could/ also record a macro and send :)
Does this work as you want for <div> (amongst others)? i.e. I think the problem is only, that you want indented behavior for more tags than what's setup by default.
Yep, works insanely great for div, exactly the behaviour I want. I just want some more tags added to the preference, like in the reccomendation I made yesterday. And of course I want that same behaviour for ALL xml-tags.
And there's also Snapz Pro X or that VNC thingie that can grab movies. You /could/ also record a macro and send :)
Ah yes of course. Can't imagine why I didn't think about that :) Could we add a pause feature to macros then, so someone watching has the possibility to catch up!
Andreas
I really like the "indent selection" menu item in the latest build. Now I can finally select the entire document and just reformat everything with good tabs. One cool macro would be to change stuff like <div> text </div> into <div> text </div>
I suppose that would be practically possible now?
This is great when you look at some other persons code, who isn't as anal about formatting and tabulation as yourself. It's also a pretty good way of enforcing your own tabulation standard in your own documents.
I still wish for the RegExp support to really take advantage of this though :D (nag nag)
Andreas
On 29/10/2005, at 17.43, Andreas Wahlin wrote:
I really like the "indent selection" menu item in the latest build. Now I can finally select the entire document and just reformat everything with good tabs. One cool macro would be [...]
I think I already mentioned it in this thread, but this is the main thing Tidy do (in addition to cleanup badly nesting and such) -- press ctrl-shift H with a HTML document, and you see the effect. It can be used on a selection as well, but for that, use ctrl-shift-cmd H (to skip the creation of standard HTML header stuff).
I still wish for the RegExp support to really take advantage of this though :D (nag nag)
Well, there is a reason why I allow users to edit these things themselves (and in this case, even document it in the help book)!
But I changed the increase/decrease patterns for HTML and XML, also extended the foldings patterns slightly, and even made it recognize an initial <!DOCTYPE broken over two lines (to have the second line indented).
For HTML I made it increase indent on all but self-closed (XHTML) tags and the few known tags w/o a closer. Though it should be compatible with people who don't trust user agents to strip initial spacing (which IIRC is only a “may” in the standard) and write their paragraphs <p>like this</p> instead of indenting after <p>.
I really like the "indent selection" menu item in the latest build. Now I can finally select the entire document and just reformat everything with good tabs. One cool macro would be [...]
I think I already mentioned it in this thread, but this is the main thing Tidy do (in addition to cleanup badly nesting and such) -- press ctrl-shift H with a HTML document, and you see the effect. It can be used on a selection as well, but for that, use ctrl-shift- cmd H (to skip the creation of standard HTML header stuff).
I feel that tidy makes a slaughterhouse of my code, and I was also thinking about "normal" code, such as C++ or PHP or JavaScript. Thanks a bunch for your patience in this matter, I will now try to be satisfied :)
Andreas