Vim Copy, Cut and Paste Commands and Operations

Vim provides different shortcuts for copy, cut and paste operations. These commands are one of the most used and problematic commands because of vim command or shortcut based work style.

Copy Current Line

We can copy current line with the yy command which is named yank. But the cursor should be located in the line we want to copy.


Copy Lines

We will again use yy command in order to copy multiple lines. But in this situation we should specify the range or line counts. We will provide the line count we want to copy between y‘s . In this example we will copy 5 lines from current cursor.


Copy Word

We can copy the next word where cursor locates with yw command. Words are separated with spaces.


Cut Current Line

We can use dd command in order to cut current line. dd command is actually used to delete line but  after delete operation the deleted line will be put into the buffer where we can use and put the line with yy command.


Cut Multiple Lines

We can cut multiple lines with dd command. In this example we will cut 10 lines by putting 10 between d commands. Cut start location is the cursor location.


Cut Word

We can cut word which is next one with dw command.



Cut and copy operations will put the content to the buffer. This buffer will be used to paste text. We will use p shortcut in order to paste last item in the buffer like below.


LEARN MORE  Awk If, If Else, Else Statement or Conditional Statements

1 thought on “Vim Copy, Cut and Paste Commands and Operations”

Leave a Comment