sublimetext - Wrap lines with tag using different logic in sublime text 2 -


i have hundreds of list items code. each list item contains title , description in 2 lines. need wrap 2 lines tag. there way using sublime text 2? using windows os.

this output needed:

<ul>     <li>         title         descrpition     </li>     <li>         title         descrpition     </li> </ul> 

raw text looks this:

this title
description
title
description

=====

i have tried using ctrl+shift+g , using ul>li* unfortunately wraps each line <li>

if possible sublime text, need type of structure:

<ul>     <li>         <span class="title">this title</span>         <span class="description">this descrpition</span>     </li>     <li>         <span class="title">this title</span>         <span class="description">this descrpition</span>     </li> </ul> 

how 2 step process using find , replace?

i assuming that:

  • your original text not indented @ all;
  • your indentation 2 spaces; and
  • you handle wrap <ul> , resultant indentation after done.

original state:

    title     description     title     description 

step one

ensuring have enabled regular expression matching find , replace using these values.

find :: ((.*\n){1,2})

replace :: <li>\n\1</li>\n

result:

    <li>     title     description     </li>     <li>     title     description     </li> 

step two

ensuring have enabled regular expression matching find , replace using these values.

find :: (<li>\n)(.*)\n(.*)

replace :: \1 <span class="title">\2</span>\n <span class="description">\3</span>

result:

    <li>       <span class="title">this title</span>       <span class="description">this description</span>     </li>     <li>       <span class="title">this title</span>       <span class="description">this description</span>     </li> 

what think?

close enough useful?


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -