Link to home
Start Free TrialLog in
Avatar of oaktrees
oaktrees

asked on

HTML Editor That Indents Code As Illustrated

Hi,

After a page of code gets a certain length it really seems to me to be unintelligible because the indenting breaks down, or is inconsistent.

I've purchased lots of text editors; HTML valdating text editors; WSYWIG programs.  Many promise to indent the code logically out of the box.  

Others say there are settings which, if selected in combination, will indent HTML so that it's easier to read.

Here's a pretty good illustration of the code appearance I'm going for: http://www.granneman.com/webdev/coding/formatting-and-indenting-your-html/

I'd be happy if I could even just get this much to work: "Best method: indent text/content ".

Is there any editor that you all know of that will do most of this formatting as you type?  Or, if it's not automatic, an editor whose settings you know can be selected with some simplicity to achieve this outcome.

Thanks!

OT
Avatar of ThomasMcA2
ThomasMcA2

HTML Tidy is a popular tool.

Notepad++ has several HTML Tidy functions:
User generated image
Avatar of oaktrees

ASKER

Hi!

Yep.  I've seen that.  You're right.  What I'm thinking of is something that constrains, forces it to be tidy as it's being entered.  An as-you-go sort of tool, so that if I typed in:

<p>Here is some amazing text that redefines the concepts of thought and philosophy.  Touching on ideas of art, history and science, what's here is compelling and asks to be read and shared.</p>

Then, that code gets auto pushed-around into a beautiful indented layout, as illustrated in the link.  Something that applies the indenting as you go.

Sincerely,

OT!
Avatar of Dave Baldwin
Since reformatting the text with tags on separate lines will add hidden white space, I would never use an editor that did that.  Too often I have to go eliminate white space because it interferes with programming or layouts.
@Dave, that intends entirely on the context of the code being developed. Since browsers remove white space from HTML, the OP's request is certainly legitimate.

@oaktrees, Notepad++ lets you assign shortcut keys to its macros and add-ins. That means you can assign whatever shortcut you want to the HTML Tidy add-in. So type your code, then press Ctrl-Shift-T or Crtl-Shift-H (or whatever shortcut you assign) and your code is instantly reformatted. That's not quite real-time, but it's pretty close.
Yes, but whitespace in the wrong place can cause PHP to fail.
Hello Dave & Thomas!

Feel grateful for the replies.  Many thanks!!

Seems what I'm driving at is a kind of as-you-type effect.  Here's my motivation: in some sense well-formatted code is a clue unto itself - a kind of topography where one can scan and see where the errors are, and how larger elements relate to each other.  More importantly: it should reveal where wrongly coded things are, and / or where those things sit.

Thomas, you're right - I could run the macro.  Seems that most of my issues arise long before I'd get to running the macro, though.  I'm making a mess of the code as I go along.  By the time I'm done I know less about how all the parts functions relative to the whole because, lacking the indentation, it's messy enough to make me feel confused: I'm not sure what I've got, even though, in many cases, it's working.  

The author of the link ( http://www.granneman.com/webdev/coding/formatting-and-indenting-your-html/ ) says that there is a way of getting most editors to handle indenting in nearly an as-you-enter fashion.  Has anyone ever done that with one of these he's mentioned, or any other editor?
My main editor is HTML-kit http://www.chami.com/ and it will auto-indent to the last indent you used when you press enter.  So does PSPad http://www.pspad.com/ .  And Notepad++ http://notepad-plus-plus.org/ .
Hello Dave!

Wow!  Awesome - great!  In HTML Kit - is there any setting, or array of setting I should select to get the outcome I'm shooting for?  Or, will it work that way pretty much out of the box?

Sincerely,

OT
I don't remember.  I've been using it for more than 10 years and I rarely change the settings for anything.
Are you using the Free one or the Pro / paid version?
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial