4

I have a code like this:

Kuu(ij,mn)=-H1/A1/AA2*R0(ij,mn)*DA1Y*DQ66Y+...
H1/A1/AAA2*R0(ij,mn)*Q66*DA1Y*DA2Y-...
1/H1/AA1/AA2*H2*R0(ij,mn)*Q66*DA1Y^2+...
1/AA1/H1*DH2X*Q11*RX(ij,mn)-...
1/AAA1*H2/H1*Q11*RX(ij,mn)*DA1X+...
1/H1/AA1/A2*H2*Q11*RX(ij,mn)*DA2X;

I want to move "H1" to the end of line. so it will become like this:

Kuu(ij,mn)=-1/A1/AA2*R0(ij,mn)*DA1Y*DQ66Y+...H1
1/A1/AAA2*R0(ij,mn)*Q66*DA1Y*DA2Y-...H1
1//AA1/AA2*H2*R0(ij,mn)*Q66*DA1Y^2+...H1
1/AA1/*DH2X*Q11*RX(ij,mn)-...H1
1/AAA1*H2/*Q11*RX(ij,mn)*DA1X+...H1
1//AA1/A2*H2*Q11*RX(ij,mn)*DA2X;H1
  • 1
    Select, Press Ctrl+X, move to the end of the line and press Ctrl+V? – Seth May 13 '17 at 8:00
  • 4
    @Seth And if the file has several thousand lines to fix? – DavidPostill May 13 '17 at 8:19
  • Are you sure you want "word", because H1 isn't a word? Don't you mean strings? If it's words, it's very different solution to simply strings. – Braiam May 13 '17 at 17:50
  • In the first and second lines of your example, you’re not moving the word “H1”, you’re moving the “H” and copying the “1”. And what do you want to happen to a line that doesn’t contain “H1”? or that contains it multiple times? – G-Man May 15 '17 at 3:26
12

I want to move the word "H1" to the end of line

  • Menu "Search" > "Replace" (or Ctrl+H)

  • Set "Find what" to ^(.*)\bH1\b(.*)$.

  • Set "Replace with" to \1\2H1

  • Enable "Regular expression"

  • Click "Replace All"

    enter image description here

Before:

Kuu(ij,mn)=-H1/A1/AA2*R0(ij,mn)*DA1Y*DQ66Y+...
H1/A1/AAA2*R0(ij,mn)*Q66*DA1Y*DA2Y-...
1/H1/AA1/AA2*H2*R0(ij,mn)*Q66*DA1Y^2+...
1/AA1/H1*DH2X*Q11*RX(ij,mn)-...
1/AAA1*H2/H1*Q11*RX(ij,mn)*DA1X+...
1/H1/AA1/A2*H2*Q11*RX(ij,mn)*DA2X;

After:

Kuu(ij,mn)=-/A1/AA2*R0(ij,mn)*DA1Y*DQ66Y+...H1
/A1/AAA2*R0(ij,mn)*Q66*DA1Y*DA2Y-...H1
1//AA1/AA2*H2*R0(ij,mn)*Q66*DA1Y^2+...H1
1/AA1/*DH2X*Q11*RX(ij,mn)-...H1
1/AAA1*H2/*Q11*RX(ij,mn)*DA1X+...H1
1//AA1/A2*H2*Q11*RX(ij,mn)*DA2X;H1

Further reading

  • 1
    Your regular expression does not treat H1 as a word, and so it will be moved even if part of a longer word like GAH1. You probably need some \bs in there, if Notepad++ supports it. – Lightness Races in Orbit May 13 '17 at 16:37
  • 2
    @BoundaryImposition True, but it meets the requirements of the question. And in the examples there are no proper word boundaries surrounding H1 – DavidPostill May 13 '17 at 16:38
  • 1
    The question is "How do I move a word to the end of line in notepad++?" – Lightness Races in Orbit May 13 '17 at 16:39
  • 2
    @BoundaryImposition H1 is not a word (by any normal definition of a word) in the examples given in the question. – DavidPostill May 13 '17 at 16:40
  • 1
    I disagree; in all examples given, it is surrounded by non-alphanumeric entities, thus meeting all common definitions of the term "word" in a context such as this. We will have to agree to disagree (at least until the OP clarifies their requirement). Good day. – Lightness Races in Orbit May 13 '17 at 16:42

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.