1

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> 

1 Answer 1

1

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 elements, 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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.