Sublime Forum

Wrap Each Line in HTML Tag (v2)

#1

Based on the information provided by adzenith about modifying the cursor location using .sel(), I’ve made another plugin that I find myself using all the time, wrap each in tag. So if you have the following text:

this is a test
And select all the lines and run the function you’ll get:

<li|>this</li|> <li|>is</li|> <li|>a</li|> <li|>test</li|>
with all the

  • s selected ready for you to overtype with whatever tag you prefer (this is based on TextMate functionality, to help my transition!). You will have to click (or press Escape) to return the cursor to a single position (unless there’s another method I don’t know about…).

    Again, if this is duplicating another plugin/built-in function please let me know! I’d always rather use original functions, than plugins!

    You can get it here:

    http://dom111.co.uk/files/sublime/plugins/wrap_each.py

  • 0 Likes

    #2

    Mind telling us how to actually trigger it?

    Looks great and I’d find this very useful.

    Thanks.

    0 Likes

    #3

    btw, you don’t need a plugin to do this:

    1. Select the lines of interest
    2. Use “Selection/Split into Lines” (Ctrl+Shift+L on Windows and Linux, Cmd+Shift+L on OS X)
    3. Use the regular “Wrap Selection with Tag” function from the command palette
    1 Like

    #4

    [quote=“jps”]btw, you don’t need a plugin to do this:

    1. Select the lines of interest
    2. Use “Selection/Split into Lines” (Ctrl+Shift+L on Windows and Linux, Cmd+Shift+L on OS X)
    3. Use the regular “Wrap Selection with Tag” function from the command palette[/quote]

    i just registered just because i wanted to say Thank you :exclamation:

    0 Likes

    #5

    Another registration just to say THANK YOU. What a staggeringly useful shortcut.

    0 Likes