Search code examples
listformatnotepad++

How to format list items using notepad++


I have a loooong list of list items that I have to format. Is there a way to do a replace all and format this:

    <li>
    aragonese</li>

    <li>
    sidamo</li>

    <li>
    altaic_languages</li>

    <li>
    luo</li>

    <li>
    papuan_languages</li>

    <li>
    khotanese</li>

    <li>
    kinyarwanda</li>

    <li>
    elamite</li>

To this?

<li>German</li>
<li>sidamo</li>
<li>altaic_languages</li>

Solution

    • Ctrl+H
    • Find what: li>\R\h*
    • Replace with: li>
    • CHECK Wrap around
    • CHECK Regular expression
    • Replace all

    Explanation:

    li>         # literally
    \R          # any kind of linebreak (i.e. \r, \n, \r\n)
    \h*         # 0 or more horizontal spaces
    

    Screenshot (before):

    enter image description here

    Screenshot (after):

    enter image description here