Reputation: 1165
Is there a setting or plugin in Sublime Text 3 that would allow me to achieve the following automatically?
<element attr1="value"
attr2="value"
attr3="value">…</element>
Upvotes: 1
Views: 144
Reputation: 61
I don't know of a plugin, but you can search for (?<=\b") +\b
and replace with \n\t
which results in a formatting close to requested:
<element attr1="value"
attr2="value"
attr3="value">…</element>
Necessary assumptions: 1) your input data was
<element attr1="value" attr2="value" attr3="value">…</element>
2) your element
had had 0 indentation.
The regex highlights a sequence of 1 or more spaces between closing quotation marks to the left and a new word beginning to the right. You can also select them all and multi-insert enter
and the 9 spaces needed in this very example. More cumbersome, restricted to one element
at a time, but pretty.
If you expect any quotation marks outside of element
s, you can use a more robust regex: (?<=\b") +\b(?=[^<]+>)
. It adds the condition that on the right you can find a closing angle bracket with no opening bracket before it.
Upvotes: 1