Reputation: 2791
When I have code like this (|
represents a cursor):
<tag>|</tag>
and press enter, I get this:
<tag>
|
</tag>
My question is, how can I quickly get from this:
<tag>text</tag>
to this:
<tag>
text
</tag>
Upvotes: 3
Views: 927
Reputation: 32006
There is not a built in way to do this. However, if your markup is:
<tag>
text</tag>
After running a code reformat (Ctrl+Alt+L) you will have this:
<tag>
text
</tag>
You can take can take advantage of this in a macro. Off the top of my head, I can not think of a macro that will handle a single word value (without any spaces between the element tags and the value) and a multi-word value. Below is the macro that will do this for a multi-word value. For a single word value, you would drop step 2. Place your cursor in the value/text area of the element. Start a macro recording (Edit > Macro >Start Recording) and record the following macro:
Stop the macro recording, and name it. Then assign a keyboard shortcut to it (Settings > IDE Settings > Keymap > Macros)
Note that the above will run the reformat on the entire file. If you only want to run it on the tag in question, add three Ctrl+W commands between step 4 & 5 to select just that element and its value. Then add an Alt+S before Step 6 (to ensure the "Selected Text" option in the dialog is always selectes).
Upvotes: 2