Formatting Code - indents / spaces

User 315488 Photo

Registered User
90 posts

Is there a way to re-format the code in the code window so that it follows some standard indenting rules?

I have tried to keep it all nicely formatted, but it always gets messed up and hard to read. I would like it to be indented 2-3 spaces/tabs for each level.

It would be nice if each level could be indented 2-3 spaces over from the one above it so the code is easy to read and easy to see where an element begins and ends.

Kind of like this:

<first level>
</first level>

It is such a pain to try to reformat it in HTML editor once it gets out of whack. It also seems that I can't keep it that way even when starting from scratch since tabbing produces different results every time it seems. Sometimes when I tab, it goes over 2-3 spaces like I want. Sometimes it goes 10, 20 or even 30 spaces over. I can't figure out a way to fix this.

Any ideas how to make this work? In other editors I've used, there is a re-format option that re-formats the entire document to settings I have pre-set to use.

If HTML editor can do this, I haven't found it (and code cleaner has mixed results at best).
Any ideas on how I can do this - even if I have to use another product to clean it up?

User 187934 Photo

Senior Advisor
19,190 posts

Click on "Tools/Preferences/Customization/Modify Options/ :)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
This is a site I built for use in my job.(HTML Editor)
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
User 38401 Photo

Senior Advisor
10,951 posts

You can also use the list settings for a definition list
<dl> Defines a definition list, that is a list of terms and their associated definitions.
<dt> Represents a term defined by the next <dd>.
<dd> Represents the definition of the terms immediately listed before it.

So you would do the <dl> in place of a <ul>
Use the <dt> in place of the <li>
and use the <dd> to indent further to put the definition or text you want indented in

Something like this:

---<dt> Text Line Here</dt>
------<dd>text indented further</dd>

I don't think you can go any deeper, I have never tried, but you might be able to put <dd> tags inside <dd> tags to indent further, give it a try and see.

That is basically HTML4/5 code for lists.

Hope that helps, and good luck with it :)
User 315488 Photo

Registered User
90 posts

That doesn't help. What I'm trying to see if HTML editor can do is to auto re-format the code window so all of the code blocks are properly indented to make it visually easy to distinguish where one block starts and ends.

As I edit and add or paste code into the editor, it never indents properly, it just keeps the current indenting or none at all. Worse, as I add new lines of code, pressing the tab key has different results. Sometimes it indents as I want it to - often it indents too little or way, way too much. I've changed the options under Tools>Preferences>Customizaton>Modify Options, but it doesn't seem to make any difference whatever.

I've attached a picture that may explain better what I want. It's important to me to have it indented / formatted properly in the code window. It helps me keep it organized and it's visually appealing. It's the OCD part of me that wants it to look organized, not random and sloppy.

I can't find anywhere in HTML Editor to make this work, but was hoping I was just missing something.
I know it doesn't make any difference to the function of the code, but I hate it being sloppy and I hate even more taking the time to manually clean it up.

Note: I've tried the code cleaner and that doesn't work either.

User 2924428 Photo

1,718 posts

Heya FisherRon, so what you are trying to accomplish is a page that flows with every indention, I don't think there is a quick way to do this, just take your time with the code.. i've been in this game for a while and all of my code doesn't line up ;) I understand that this is a need for professional coders, but you'll get quick with it eventually.. Maybe the new HTML editor will include a feature like this.. but for now I think it's all hands on.:/
User 1948478 Photo

Senior Advisor
1,850 posts

FisherRon wrote:
...Worse, as I add new lines of code, pressing the tab key has different results. Sometimes it indents as I want it to - often it indents too little or way, way too much. I've changed the options under Tools>Preferences>Customizaton>Modify Options, but it doesn't seem to make any difference whatever...

I have found that I can get consistent tabbing if I leave "Tab Columns" blank and set "Tab Stop" to the number of spaces I want to indent for each press on the Tab key, typically 2 or 4.

As for the broader issue of having more automated indentation as you describe, e.g. by the Code Cleaner, I would certainly welcome this also! In my experience, the Code Cleaner does improve the indentation somewhat, but not enough. I seem to recall that the Code Cleaner used to do a better job of indentation in some previous incarnation, but I may be wrong...
User 46222 Photo

Registered User
4 posts

User 10077 Photo

Senior Advisor
1,073 posts

I have the same issue. When programming large applications, it's important to have the code clean to keep track of the program flow. Based on what I've experienced, HE seems to indent based on the line above. For example,

// this is what the code should look like
if($archivecount > 0){
// process goes here

// HE seems to set the next tab based on the space of the
// line above the tab stop producing code like this:
if($archivecount > 0){
// process goes here

In my opinion, it would be best if the tab stops were specifically set to a number of spaces rather than based on the line above. Perhaps that's a feature that could be added to a future version.
Personal & Specialized Help for Coffeecup Users including training for Site Designer, Form Designer and Web Form Builder via Zoom
Email me at or call 865-687-7698

How-To Instructions for Coffeecup Users (tutorials, examples, and downloads) … -users.php
User 2887210 Photo

Registered User
1 post

The ability to re-format would be a nice feature for CoffeeCup to add. Other tools like XMLSpy and Eclipse call it "pretty print" or "format code" and it is a great help when you have to work on code someone wrote before you. It's easy to write clean code from scratch. It's a lot of work to re-format code someone else wrote (and modified) years ago.
User 122279 Photo

Senior Advisor
13,163 posts
Online Now

+1000 !
I've had to clean and responsify the code on an about 100 pages' site created by someone else in '96, and I can confirm the problems you mention.
There is something called a Code Cleaner in the HTML Editor, but when you have real old code with the html tags containing the 'styling', divs without class names e.g. it doesn't work quite as intended.
Ha en riktig god dag!
Inger, Norway
My new honey site, built with RFF:
Component sharing for RFF, RBB, RSD and SD:

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.