Search code examples
notepad++

Concat multiple columns in notepadd++


I have below 2 columns data , I want to concat them together side by side in notepadd++. Can someone please help how to do this.

column1

cluster_identifier
cluster_parameter_group
db_parameter_group
instance_class
cluster_instance_count
engine

column2

= "{{ sdf.cluster_identifier }}"
= "{{ sdf.cluster_parameter_group }}"
= "{{ sdf.db_parameter_group }}"
= "{{ sdf.instance_class }}"
= "{{ sdf.cluster_instance_count }}"
= "{{ sdf.engine }}"
= "{{ sdf.engine_version }}"

final version in notepad++

cluster_identifier      = "{{ sdf.cluster_identifier }}"
cluster_parameter_group = "{{ sdf.cluster_parameter_group }}"
db_parameter_group      = "{{ sdf.db_parameter_group }}"
instance_class          = "{{ sdf.instance_class }}"
cluster_instance_count  = "{{ sdf.cluster_instance_count }}"
engine                  = "{{ sdf.engine }}"
engine_version          = "{{ sdf.engine_version }}"

Solution

  • It seems that the second column is build from the first column. Then I'd do something like this:

    • Ctrl+H
    • Find what: ^.+$
    • Replace with: $0\t= "{{ sdf.$0 }}"
    • CHECK Wrap around
    • CHECK Regular expression
    • UNCHECK . matches newline
    • Replace all

    Explanation:

    ^           # beginning of line
    .+          # 1 or more any character but newline
    $           # end of line
    

    Replacement:

    $0              # the whole match
    \t              # a tabulation
    = "{{ sdf.      # literally
    $0              # the whole match
     }}"            # literally
    

    Screenshot (before):

    enter image description here

    Screenshot (after):

    enter image description here