Auto close html tags

Started by Kluyg, October 15, 2009, 03:14:46 PM

Previous topic - Next topic

Kluyg

Is there ability to automatically (by hotkey) add close tags when editing html files?

alex

Hi Kluyg,

welcome on forum, and thanks for a feedback!

Auto close of the tags is rather specific function for XML based languages only, but I am trying to keep HippoEDIT language/syntax independent and have all functionality described by syntax schemes. As introduction :)

So there is no specific command for this and I do not plan to add it to core. And it is also difficult to some how model it. Because maybe adding close tag defined in syntax schema would be possible, but what you want is also </ tag > for it. And signs </ > are not described in schema as part of scope tag.

BUT: you have code templates, which can help in adding of pairs of open/close tags by one key stroke. You can also use there selected text and surround selection by smth on Ctrl+B.
In addition I am currently working on scripting (would be available in 1.50) which would be used then for extension of HE with all syntax related functionality as closing of tag. Script would be callable by short cut also. In addition it would be possible to subscribe script to some event, like onChar, and then do something if </ is typed.
Maybe I would provide some set of such scripts as examples then.

Best regards,
Alex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Kluyg

Hi Alex,

Thanks for the answer!

Keeping HippoEDIT syntax independent is good idea. I can live without automatic tag closing :) There are a lot of features in HE, I just don't want to miss any. Looking forward to version 1.50, good luck!

Thanks,
Mikhail

Stefan

Hi Mikhail and welcome ;)

Just to make this more clear: as Alex already mentioned ... "you have code templates"

So if one edit an HTML file and write f.ex. <table  you see an pop-up/tool-tip,
just press the TAB-key and see what happens ;D
Or try writing <a and then the TAB-key. It's magic...
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

Kluyg

It's great! But unfortunately it adds tags in uppercase which is not what I want. Can I change this behavior somehow?

Stefan

Quote from: Kluyg on October 16, 2009, 07:49:02 PM
It's great! But unfortunately it adds tags in uppercase which is not what I want. Can I change this behavior somehow?

- open an HTML file
- Go to "Tools > Syntax settings (HTML)... > Code Templates"
or
- Go to "Tools > Syntax settings (HTML)... > Miscellaneous > Edit User File"
there you can modify all templates.


But this would be some work to do.
Maybe this would be an features suggestion: implement an option to choose the case of CodeTemplations.

I mean something like as with:
"Tools > Options... > [+ ] Formating > Smart Helpers > Case correction"
for keywords.
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

As far as I remember my code ;) if you would check Format after every paste and select for Case correction lowercase for example, then pasted template would be also formatted and all tag names would be automatically converted to lowercase. Or you can use Format Selection keeping Case correction set to desired value.

But probably better is to once convert template source to format you like and forget about it.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Kluyg

QuoteAs far as I remember my code ;) if you would check Format after every paste and select for Case correction lowercase for example, then pasted template would be also formatted
Just FYI - pasted templates are not formatted and tag names remains uppercase even if Format after every paste and Case correction lowercase are set.
I have fixed "html_user.xml" file as Stefan suggested. Also FYI: I was having problems modifying this file, because it is itself case-sensitive (Firstly I have selected all it's text by ctlr+A and converted it to lowercase by ctrl+L and... all templates disappeared. Fixed it by reinstalling HippoEDIT).
I've attached the resulting fixed "html_user.xml" file. It is located at "C:\Program Files\HippoEdit\data\syntax\html_user.xml"

alex

Hi Mikhail,

yes you are right. Just double checked - the formatting of inserted template is only done, when multi-line template is inserted :/
By initial logic, formatting was used more for correcting of the indent, but not a case. Because of this if you do formatting automatically when editing one line it would "jump", that is why it was disabled for this case.
Maybe this is a bug, when thinking about case correction, I would check and maybe extend the logic to apply only case correction in case of one line templates.

I have checked, explicit Format Selection it works with correction of case, but I think this is not what not want.

Yes, schema file is case sensitive. And thanks for converting it to lower case. From one side I can replace default code templates by lower case version from you, or from another side I can place it in the library in HTML section as additional file, that people can access it. Also can be moved to Syntax Files board to HTML post.

Best regards,
Alex.

HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan


- Oh, i am too late. Alex was first. My post was delayed by family-things  ;D

-----------------------------------------------------------------------------



Hi Mikhail, thanks for sharing!

----------
Test:

"Tools > Options... > [+ ] Formating > Smart Helpers > Case correction" = lowercase
"Tools > Options... > [+ ] Formating > Smart Helpers > Smart Helpers" = [X]Format after every paste

Result:

<table>
<tr>
<td>

<TR></TR>
<FONT SIZE=""></FONT>
<A HREF="huhu">jojo</A>
<table>
<tr>
<td>

<td>
</table>
<td>
</table>


-------------------

Test 2:
> Or you can use Format Selection keeping Case correction set to desired value.


"Tools > Options... > [+ ] Formating > Smart Helpers > Case correction" = lowercase
"Format > Format Selection" or "Format > Format All"

All (selected) keywords are case changed following the "Smart Helpers > Case correction" setting.
All non-keyworks (all other words) are not case changed. Fine!
I have also noticed that the indenting was optimized.

Is it that what "Format > Format Selection" should work?
Then i would suggest to change the name of this item.
Perhaps to something like:
"Format > Format Keywords in Selection" and "Format > Format All Keywords"

So i can better guess what this option does.
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

Hi Stefan,

no main purpose of the Format Selection is to adopt indentation levels and only then case correction.
So changing to Format Keywords in Selection would be not really correct.

Best regards,
Alex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]