Oeasy teaches you to play VIM – 39 – # cut and paste

Time:2022-4-13

Cut and paste

Recall the last lesson

  • We reviewed the whole subject in a big waymotion
  • Direct movement

    • h j k l
  • Line movement

    • First lineg g
    • Last lineG
    • Line nn G
  • Word movementwbe

    • wIt’s to the next onewordBeginning of
    • bYes to the currentwordBeginning of
    • eYes to the currentwordThe end of
    • exceptwordBesidesWORD
  • Beginning and end of line

    • ^Is the first non empty character to the line
    • 0Is the first character of the line, whether it is a space or not
    • g_Is the last non empty character to the line
    • $Skip to the last character of the line, even if it is a space
  • Intra line jumping and clinging

    • towardsfrontJump isf
    • towardsafterJump isF
    • towardsfrontClose yest
    • towardsafterClose yesT
  • Full text search

    • If you look for it/
    • Reverse search is?
  • Text block

    • {}Move by paragraph
    • ()Move by sentence
  • thesemotionFinedIt can be used together to complete the work of rapid deletion
  • It can also be used in the process[count]Double
  • Delete the content and put it in""Register
  • Can cooperate and repeat.
  • And some of the previous commands can have a new understanding

Look back

  • Some of the original operations can be written in a new way

    • D corresponding to D$
    • X corresponds to DL
    • X corresponds to DH
    • Experience the joy of exercising your left ring finger
  • Delete the content and put it in""Register
  • Then delete this thing
  • Put it in the register
  • I want to paste it somewhere else
  • What shall I do?

About pasting

  • If you paste it, you should delete it from thisdIt’s not far
  • h dFind the cut help file inchange.txt
  • In the file5.copying and moving textin
  • Can findpPaste the corresponding command

Oeasy teaches you to play VIM - 39 - # cut and paste

  • nopaste
  • pCorresponding toputPut it on
  • What do you put on it?
  • holddPut something in the register

Do it

  • Let’s try

    • Let’s enter a lineoeasyThen he was testeddd
    • This timeoeasyThis line enters the register""Yes
    • thenpA moment later, there will be oneoeasy
    • 9 pWill appear9that ‘s okoeasy
    • Really!!!
  • But there are two of themp

    • One is calledpbe supposed toafter cursor
    • The other is calledPbe supposed tobefore cursor

Oeasy teaches you to play VIM - 39 - # cut and paste

  • What do you mean?

Up and down

  • Delete all firstg g d G
  • Let’s adjust the ruler first:ru
  • Then insert1that ‘s ok9individual1

    • 9
    • iEnter insert mode
    • input1
    • escReturn to normal mode
    • oLine feed return
  • Then insert1that ‘s ok9individual2

    • beforeescEnter normal mode (to interrupt the input state)
    • iEnter insert mode
    • input2
    • escReturn to normal mode
    • 8.

      • Repeat insert 28second
    • oLine feed
    • esc
  • Then try inserting again1that ‘s ok3

    • The method is the same as above
  • Insert last lineoeasy

    • Combined used dDelete him
    • That is, put him in""In the default register

Oeasy teaches you to play VIM - 39 - # cut and paste

Experience up and down

  • Let’s move the cursor to the second2that ‘s ok
  • pThis time
  • register""MediumoeasyWill put2222222...oflowernoodles

Oeasy teaches you to play VIM - 39 - # cut and paste

  • useuUndo the previous operation
  • Let’s try againP, capitalized

    • Let’s move the cursor to the second2that ‘s ok
    • PThis time
    • register""MediumoeasyWill put2222222...ofuppernoodles

Oeasy teaches you to play VIM - 39 - # cut and paste

  • How did he know it was a business?

details

  • What if there is not a whole line in the register?
  • Let’s go first:regLook at the register""

Oeasy teaches you to play VIM - 39 - # cut and paste

  • Register exceptoeasyThere’s another one^JIt means including line breaks
  • We don’t need it this timedd
  • We used$

    • motionyes$It means to the end of the line
    • That’s itoeasyPut it in the register""
    • Take a look:reg
    • ^JThe line feed is gone!
    • P one!

Oeasy teaches you to play VIM - 39 - # cut and paste

  • Is this p also case sensitive?

    around

  • Move the cursor to222222...The first5individual2
  • thenp

Oeasy teaches you to play VIM - 39 - # cut and paste

  • He’s right there5individual2 behindInsert register contents
  • uCome back and put it on the second floor5individual2upper
  • thenP
  • He’s right there5individual2 frontinsert

Oeasy teaches you to play VIM - 39 - # cut and paste

Routine operation

Oeasy teaches you to play VIM - 39 - # cut and paste

  • DW is delete word

    • There is no newline character deleted here
    • Note that the following spaces are also deleted
    • Put them into the register together
  • Wel is the moving position

    • Next word header to t
    • O from the end of the next word to to
    • Space to the right
  • P is pasted after the cursor

Common interchange characters

Oeasy teaches you to play VIM - 39 - # cut and paste

  • X deletes the current character
  • P is pasted at the back

summary

  • Our content this time is paste
  • The pasted content is:regContent in
  • Content on""Register
  • If:regOne or more rows are deleted

    • When pasting, paste it above or below the current line
  • If:regThe deletion does not include line breaks

    • Then paste it in front of or behind the current position
  • p

    • If there are rows in the clipboard

      • Then paste under the cursor
    • If there is no line in the clipboard

      • Then paste after the cursor
  • P

    • If there are rows in the clipboard

      • Then paste on the cursor
    • If there is no line in the clipboard

      • Then paste in front of the cursor
  • Case corresponds to the paste position
  • With delete and paste, we can actually cut
  • But if I want to copy and paste, what should I do?
  • Next time

[GitHub address](https://github.com/overmind19…)
[gitee address](https://gitee.com/overmind198…)
[invitation code of Lanqiao experimental building fjwyimgb](https://www.lanqiao.cn/course…)