Bash Programming

How to Cut and Paste in Vim?

“Vim is the most commonly used text editor of the Linux operating system that comes with different modes of operation. It offers almost all those features that you can expect from a good text editor. This guide is designed to share with you the method of cutting and pasting in the Vim text editor in Linux Mint 21.”

How to Cut and Paste in the Vim Text Editor?

For cutting and pasting some text in the Vim text editor, you will have to proceed as explained in the following steps:

Step # 1: Open the Desired File With the Vim Text Editor

First, your file should be opened within the Vim text editor. You can either do this via the terminal or through the GUI of your system. The file that we will be used for demonstrating this method is shown in the image below. From this file, we will be cutting the first line, i.e., Hello, and will be pasting it after the exclamation mark on the last line of the file.

Step # 2: Enter the Visual Mode and Select the Text to be Cut

Now, we will point our cursor to the start of the file from where we have to begin our selection and enter the visual mode by pressing the “v” key on the keyboard. After that, by making use of the arrow keys, we will select the desired text as shown in the following image:

Step # 3: Cut the Selected Text

Then, after selecting the text to be cut, we will press the “d” key from the keyboard, and the selected text will disappear from our file, as shown in the image below:

Step # 4: Paste the Cut Text at the Desired Location

Finally, by using the arrow keys, we will point our cursor to where we want to paste the text that we have previously cut. After reaching the desired location, we will simply press the “p” key, and the selected text will be pasted over there, as shown in the following image:

Once you are done with your cutting and pasting, you can simply save your file and exit the Vim text editor.

Conclusion

By following the same lines, you can cut and paste any desired text, even from larger files, while making use of the Vim text editor in Linux. However, once you are done making these changes, do not forget to save your file before exiting the editor.

Similar Posts