uicoded
uicoded

Reputation: 625

How to efficiently generate ordered list from couple of lines with Sublime Text?

How to efficiently generate ordered list from couple of lines?

Let's say:

list item 1
list item 2
list item 3

into:

<ul>
  <li>list item 1</li>
  <li>list item 2</li>
  <li>list item 3</li>
</ul>

Notes:

I could deduct the select_lines from documentation, the problem was:

Upvotes: 0

Views: 1592

Answers (1)

Sergey Telshevsky
Sergey Telshevsky

Reputation: 12217

On Mac, can be used on windows as well with a bit of changing the shortcuts.

  1. Put the cursor before the first character of the first line.
  2. Hold ctrl+shift and press arrow down 2 times, this will create 3 cursors at each line.
  3. Holding cmd+shift press arrow right to go to the end of the lines while selecting, this will select each line separately.
  4. Press ctrl+shift+w to wrap with tags and immediately start typing li. It will type on both tags at the same time - on the opener and the closing tag
  5. Press esc to cancel multiple selections.
  6. Now select as you normally would the whole list including one line above and one line below the list.
  7. Repeat the step 4., but type ul.

Now all keybinding are default Mac bindings, on Windows/Linux you may find your bindings in the key bindings config. Just for reference I will write down all that were used so you could find them easier:

{ "keys": ["ctrl+shift+w"], "command": "insert_snippet", "args": { "name": "Packages/XML/long-tag.sublime-snippet" } },
{ "keys": ["ctrl+shift+down"], "command": "select_lines", "args": {"forward": true} },

The cmd+shift+arrow right is the same as pressing shift+end on Windows and Linux.

Upvotes: 2

Related Questions