On 2020/10/10 23:10, Gary Johnson wrote:
> On 2020-10-10, L A Walsh wrote:
>
>> :%s/>/>^M/g
>> :%s/<\([^>]\+\)>\n\([^>]\+\)<\/\1>/<\1>\2<\\\1>
>>
>
> I don't know of a way to do that with one command, ....
> then execute the following
> normal-mode command.
>
> gg=G
>
---
close enough, as I gave 'ggap' as an example for text.
> You might also search the web for HTML Tidy. I think it will
> reformat an HTML file.
>
---
yeah, but it was xml and main requirement was to run
pretty much in (g)vim. You got like 100% for my original
question! But ran into a quirky special case that fails with
normal vim indenting as well (works if I split all
lines 1st), but if some of the close tags are on same line
as open, doesn't seem to unindent...
Example, starting with:
<xml>
<totalbytes>2952962267<\totalbytes>
<image index="1">
<dircount>13363<\dircount>
<filecount>64267<\filecount>
<totalbytes>11707704502<\totalbytes>
<creationtime>
<highpart>0x01cb8936<\highpart>
<lowpart>0x131f339a<\lowpart>
</creationtime>
<lastmodificationtime>
<highpart>0x01cb8950<\highpart>
<lowpart>0xbc4d774b<\lowpart>
</lastmodificationtime>
<doors>
<arch>9<\arch>
<hal>acpiapic<\hal>
<languages>
<language>en-us<\language>
<default>en-us<\default>
</languages>
<systemroot>doors<\systemroot>
</doors>
<hardlinkbytes>4497873056<\hardlinkbytes>
</image>
</xml>
Running '=' over that, (filetype=xml, syn=xml) using expand tab, I get:
<xml>
<totalbytes>2952962267<\totalbytes>
<image index="1">
<dircount>13363<\dircount>
<filecount>64267<\filecount>
<totalbytes>11707704502<\totalbytes>
<creationtime>
<highpart>0x01cb8936<\highpart>
<lowpart>0x131f339a<\lowpart>
</creationtime>
<lastmodificationtime>
<highpart>0x01cb8950<\highpart>
<lowpart>0xbc4d774b<\lowpart>
</lastmodificationtime>
<doors>
<arch>9<\arch>
<hal>acpiapic<\hal>
<languages>
<language>en-us<\language>
<default>en-us<\default>
</languages>
<systemroot>doors<\systemroot>
</doors>
<hardlinkbytes>4497873056<\hardlinkbytes>
</image>
</xml>
----
Seems if I have some closing tags on same line it doesn't
unindent (happens in normal insert as well). Seems unrelated
to the method you gave. I have seen the indent problem in other
languages as well, but am stymied coming up with
an example off the top of my head.
To emphasize, if all the tags (open+close) are on their
own line, it works just fine. But when some matching tags
are on same line, I get mixed/weird results.
Anyone seen such fun? And thanks again gary, for the '=',
don't recall ever seeing that.
*cheers*
-linda