Copy And Paste In Vi


Answer :


  1. Move the cursor to the line from where you want to copy and paste contents at another place.

  2. Hold the key v in press mode and press upper or lower arrow key according to requirements or up to lines that will be copied. you can press key V to select whole lines.

  3. Press d to cut or y to copy.

  4. Move the cursor to the place where you want to paste.

  5. Press p to paste contents after the cursor or P to paste before the cursor.



You have



 :set paste


Put Vim in Paste mode. This is useful if you want to cut or copy
some text from one window and paste it in Vim. This will avoid
unexpected effects.
Setting this option is useful when using Vim in a terminal, where Vim
cannot distinguish between typed text and pasted text.



Assuming your vi is actually vim, before pasting, do:



:set paste


That disables word wrapping and auto-indent and all similar things that modify typed text. After pasting, turn it off again with



:set nopaste


The reason is that while gvim can tell pasting from typing (so you don't need this when using gvim), the terminal version can't, because it's the terminal doing copy and paste and vim simply sees the text as typed. And therefore applies the transformation like it does for any other text.



Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable