Move one line

Help
2002-07-21
2013-05-02
  • I often want to move one line in a file to another place in the same file. Is there way than marking the line to be moved as a block of text and then ^KM it? I know ^Y will delete a line, but is there a command to paste that deleted line back under the cursor (as opposed to ^_, which puts it back where it came from)?

    Thanks, Sue

     
    • I've been trying to find out exactly the same thing. Recently mailed author of joe to ask if this can be done.

      K.

       
    • Yes, that command is yankpop, commonly bound to ^[ Y.

       
    • The yankpop command (usually bound to ^[ Y) pastes the last deletion at the point. The last deletion might have been more consecutive delete commands so if you delete more lines by pressing ^Y many times at once you can paste them at once. If you press ^[ Y repeatedly, you can rotate through the last few deletions.
      I use this command very often. This is actually the normal way of moving text around in emacs, vi, and pico; but joe has inherited the other way (^K ^M and ^K ^C) from wordstar.