Search code examples
regexsublimetext3

Making use of Macros in sublime for regular expression matching


I have the following lines in sublime

 = "COLUMN"
 = "COLUMNS"
 = "COMBIN"
 = "COMPLEX"
 = "CONCAT"

I want to add what is inside of the double quotes to the begining of the line. Output will be

 COLUMN = "COLUMN"
 COLUMNS = "COLUMNS"
 COMBIN = "COMBIN"
 COMPLEX = "COMPLEX"
 CONCAT = "CONCAT"

The file is big with more than 1000 records. Can this be done with sublime macro ?


Solution

  • This doesn't require macros. Instead can be done with Sublime replace patterns

    Choose Find -> Replace from the menu.

    Enable regular expression by clicking .* button on the left hand side.

    Find String:

    ^ = "([A-Z]+)"
    

    Replace String

    \1 = "\1"