0

I want to swap to lines that start with an specific word with each other (mind you, the FULL line) automatically, using replace with regex or whatever else, here's an example on what I want to do:

  • The lines are like this:

    culture = x  
    religion = x  
    
  • And I want to make them like this:

    religion = x  
    culture = x  
    

The lines aren't adjacent... I actually meant rows I believe. Excuse me but I'm not a connoisseur of all this.


I guess an script would be more appropriate. Care to provide one?

  • 1
    Are the lines always adjacent? What's the expectation if you have line1, line2, then line1 again? – ernie Nov 18 '13 at 19:37
0

In Vim it can be done with

:s/^\(culture =.*\n\)\(\(.*\n\)*\)\(region =.*\n\)/\4\2\1/

In Notepad++, disable the “. matches newline” option, enable regular expressions and fill in

Find what: ^(culture =.*\R)((.*\R)*)(region =.*\R)
Replace with: \4\2\1

For details see Notepad++ regular expressions syntax.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.