Command to convert selected lines to HTML bulleted list in Sublime Text?

Steve picture Steve · Mar 2, 2014 · Viewed 8.3k times · Source

Whenever I have a series of lines that are supposed to be a bulleted list (UL) in Sublime Text 3, I need to repeat these steps:

  1. Select the lines
  2. Use "split selection into lines (shift-command-L)
  3. Wrap selection with tag (ctrl-W) and type LI
  4. Re-select the 4 lines
  5. Wrap selection again with UL this time (or just manually type UL and /UL)

This is tedious. Does anyone know of a built-in command, a plug-in, or a macro that will take selected lines, wrap each line with an LI tag and the selection with the UL tags in one go?

Answer

zumek picture zumek · Jul 14, 2014

You can easily achieve this if you have the Emmet plugin installed. The feature that you're after is called "Wrap with abbreviation".

Steps needed:

  1. Select the block of text
  2. Press CTRL+SHIFT+G (on Windows), and;
  3. enter ul>li* in the input field that opens up at the bottom of the window (same as where "Find" comes up).
  4. Profit! :)

It's also possible to do some further cool stuff using filters with this as well. Be sure to check out the Emmet docs.