XML Pretty Print

738 views
Skip to first unread message

Mike Margerum

unread,
Jun 15, 2017, 10:01:51 AM6/15/17
to BBEdit Talk
I used to be able to reformat / prettyify XML from BBEdit, but somewhere along the way this was removed.  It's probably one of the top things I need from the editor as I deal with a lot of XML.

Is it back yet?  If so, how do you access it?  I see a format in the markup menu, but it looks like its only for HTML?

Thanks

Patrick Woolsey

unread,
Jun 15, 2017, 12:23:18 PM6/15/17
to bbe...@googlegroups.com
Not yet, but please drop a note to tech support
<sup...@barebones.com> and we may be able to help you with an
interrim solution.

Regards,

Patrick Woolsey
==
Bare Bones Software, Inc. <http://www.barebones.com/>

Dave

unread,
Jun 16, 2017, 8:21:29 AM6/16/17
to BBEdit Talk
You should have a program called xmllint in your /usr/bin/ directory that can parse and reformat an xml file, stream or URL. Since it can process standard input and output to standard out, it can be used in a text filter. See the user manual and http://bbeditextras.org/wiki/index.php?title=Text_Filters for more information on how to create and use text filters. See man xmllint or xmllint --help for more about xmllint.

Jim Danner

unread,
Jun 16, 2017, 10:02:23 AM6/16/17
to BBEdit Talk
As Dave says, xmllint is a useful utility for this. My script Tidy up XML.sh looks like this:
#!/bin/bash
#
# Tidy up an XML file

XMLLINT_INDENT
=$'\t' xmllint --format - | \
sed
-E 's/^([[:blank:]]*)(<[^<>]+>)(.*)(<[^<>]+>)$/\1\2\
\1'
$'\t''\3\
\1\4/'

I added the sed command to insert some more line breaks in the XML for clarity, but you can choose to do without (by removing everything starting from the | pipe).

Iris Panabaker

unread,
Aug 11, 2017, 8:14:58 AM8/11/17
to BBEdit Talk
I like to use https://jsonformatter.org/xml-pretty-print for xml pretty print and xml formatter

F. Alfredo Rego

unread,
Aug 11, 2017, 11:44:35 AM8/11/17
to bbe...@googlegroups.com
Is there a keyboard shortcut to toggle Soft Wrapping? 

Being lazy, I would like to avoid having to do a couple of pointing and clicking kinds of maneuver/manoeuvre/manœuvre/Manöver/maniobra/manovra using this:


Thanks to our distinguished intercontinental and multilingual community for any guidance. Sorry if I failed to include YOUR language, but I’m sure you’ll get the point (so to speak ;-)

Alfredo

--
This is the BBEdit Talk public discussion group. If you have a
feature request or would like to report a problem, please email
"sup...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To post to this group, send email to bbe...@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.

Fletcher Sandbeck

unread,
Aug 11, 2017, 12:02:57 PM8/11/17
to bbe...@googlegroups.com
You can assign one. Open Preferences and select Menus & Shortcuts. Find "Status Bar" in the list and you'll find "Soft Wrap Text" within the "Text Options" and can assign a shortcut there.

[fletcher]


On Aug 11, 2017, at 8:44 AM, F. Alfredo Rego <F.Alfr...@gmail.com> wrote:

Is there a keyboard shortcut to toggle Soft Wrapping? 

Being lazy, I would like to avoid having to do a couple of pointing and clicking kinds of maneuver/manoeuvre/manœuvre/Manöver/maniobra/manovra using this:

<BBEdit091.png>

Neil Faiman

unread,
Aug 11, 2017, 12:05:14 PM8/11/17
to BBEdit Talk Mailing List
On Aug 11, 2017, at 11:44 AM, F. Alfredo Rego <F.Alfr...@gmail.com> wrote:
>
> Is there a keyboard shortcut to toggle Soft Wrapping?
>
> Being lazy, I would like to avoid having to do a couple of pointing and clicking kinds of maneuver/manoeuvre/manœuvre/Manöver/maniobra/manovra using this:

BBEdit > Preferences, Menus & Shortcuts, choose View in the left pane, Text Display > Soft Wrap Text in the right pane, and set the keyboard shortcut of your choice. ( Or Status Bar in the left pane, Text Options > Soft Wrap Text in the right pane.)

Regards,

Neil Faiman

F. Alfredo Rego

unread,
Aug 11, 2017, 2:54:05 PM8/11/17
to bbe...@googlegroups.com
Thanks, Neil and Fletcher. This worked perfectly.

I certainly need to dive into BBEdit’s wonderful preferences in more detail.

I appreciate your guidance.

Alfredo

> On Aug 11, 2017, at 10:05 AM, Neil Faiman <neil....@faiman.org> wrote:
>
> BBEdit > Preferences, Menus & Shortcuts, choose View in the left pane, Text Display > Soft Wrap Text in the right pane, and set the keyboard shortcut of your choice. ( Or Status Bar in the left pane, Text Options > Soft Wrap Text in the right pane.)
>
> Regards,
>
> Neil Faiman



Reply all
Reply to author
Forward
0 new messages