Contents

NotepadPlusPlus

Website Visitors:

Convert vertical words to horizontal with double quotes and comma

If you have content in a line like shown below,

apple banana lemon watermelon

you want to add double quotes and add comma and bring them to a single line.

You won’t be able to do it in a single replacement; you’ll have to perform a few steps. Here’s how I’d do it:

  1. Find (in regular expression mode):

    1
    
    (.+)
    

    Replace with:

    1
    
    "\1"
    

    This adds the quotes:

    1
    2
    3
    4
    
    "apple"
    "banana"
    "lemon"
    "watermelon"
    
  2. Find (in extended mode):

    1
    
    \r\n
    

    Replace with (with a space after the comma, not shown):

    1
    
    , 
    

    This converts the lines into a comma-separated list:

    1
    
    "apple", "banana", "lemon", "watermelon"
    

Your inbox needs more DevOps articles.

Subscribe to get our latest content by email.