How to Copy & Paste Using VI
VI is a command line text editor for the Unix and Linux operating systems. Some Linux distributions use the Vim (VI enhanced) text editor, which is an enhanced version of the original VI text editor. VI and Vim use keyboard shortcuts for every action, including copying and pasting text. To use the shortcuts, you must place the editor in the command mode. In this mode the keys that are pressed are not visible on the screen.
Instructions
-
Copy the Entire Line
-
1
Open a terminal window.
-
2
Type the command "vi" to open a blank file in the VI text editor. If you want to open a file, type the command "vi filename." Replace the word "filename" with the name of the file.
-
-
3
Press the "Esc" key to go to command mode.
-
4
Place your cursor at the beginning of the line that you want to copy.
-
5
Type "y" to copy the entire line. If you want to copy the next 5 lines type "y5." If you want to copy all the lines to the end of the file type "yG."
Copy a Single Word
-
6
Press the "Esc" key to go to command mode.
-
7
Place your cursor at the beginning of the word that you want to copy.
-
8
Type "yw" to copy the word after the cursor.
Copy to End of Line
-
9
Press the "Esc" key to go to command mode.
-
10
Place your cursor at the beginning of the portion of the line that you want to copy.
-
11
Type "y$" to copy from the cursor to the end of the line.
Paste
-
12
Press the "Esc" key to go to command mode.
-
13
Place your cursor where you want to paste the text.
-
14
Type "P" (uppercase P) to paste the text above, or before, the cursor. Type "p" (lowercase p) to paste the text below, or after, the cursor.
-
1