English
+370 5 205 5502 sales@monovm.com

How to copy, Cut and Paste in Vim/Vi Editor? [VIM Copy Paste]

While working with any text files in VIM; Copy, cut, and paste is the most common task, During this article, you will know How to Copy, Cut and Paste in Vim/Vi Editor?

04 Apr, 22 by Susith Nonis 3 min Read

List of content you will read in this article:

Vim is a most powerful Linux text editor that can carry out all kinds of content management tasks; also boost your productivity. In this article, we will be helping you out with How to copy, paste and cut in VIM Editor for any content in a clipboard using Vim commands. 

VIM is one of the best text editors commonly used in Command-line interface and Graphical User Interface environments. It is free and open-source software. It is the modified version of the vi editor. Some significant differences make Vim a better choice compare to the vi editors listed below.

Go to the desired location in the text editor, press y, and move the cursor to the specified location. Alternatively, you could also make use of the following options to perform the same task in another manner.

  • yy: Replace the current line with the newline character.
  • 3yy: Copy three lines, beginning with the line that has the cursor.
  • y$: Copies everything from the cursor to the line's end.
  • Yw: Copy to the starting of the next word.
  • yiw: Copy the word that the cursor is pointing to.
  • y%: Copy all the matching characters. By default, supported pairs include [], {} and (). This is useful for copying text between matching brackets.

Go to the desired location in the text editor, press d, and move the cursor to the specified location. Alternatively, you could also make use of the following options to perform the same task in another manner.

  • dd: Remove the current line (including the newline character).
  • 3dd: Cut three lines, beginning with the line where the cursor is pointed.
  • d$: Cut everything from the cursor to the line's end.

Press to paste the copied text after the cursor and P to paste it before the cursor.

In this article, we went through the Copy, Cut, and Paste commands in the Vim text editor. There are several copies and cut options that we can make use of to copy the content in various patterns. The pasting can be done with a single click of a button. If you do have any other methods for Copying, Pasting, and Cutting in Vim editor you can suggest them via the comment section below.

People are also reading:

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I veture into the world of Technology I try to share what I know in the simplest way possible. Not a fan of coffee, a sweet addict and a self accredited 'master chef'.