How can I copy and pest in command mode in vim editor?

Asked By 110 points N/A Posted on -
qa-featured

How can I copy current word, letter and line and pest them on Vim editor in Linux OS?

SHARE
Best Answer by Sharath Reddy
Answered By 0 points N/A #133486

How can I copy and pest in command mode in vim editor?

qa-featured

Hi Marty,

There are many options in vim editor to perform word processing. 

This is a very powerful editor in Linux world. If you learn Linux OS you must should learn vim cause you always find this editor in different vendors in Linux.

Ok, here your answers below.

When you open a file with Vim editor and if you want to copy a letter just put cursor at letter  then press the key y and 1 one after another that's it.

y1      copy current letter
yw     copy current word
yy      copy current line

For pest you just need to press the letter  “p”

Britnu Salu

Best Answer
Best Answer
Answered By 590495 points N/A #133487

How can I copy and pest in command mode in vim editor?

qa-featured

The “vi” editor which is pronounced as “vee-eye” is a very strong tool in Linux which can operate in two different modes: the command mode and the insert mode. It is integrated with a massive manual which you can activate using the command “:help” without double quotes after starting the program.

On the other hand, you can also use the commands “man” or “info” as an alternative but it contains rather small information than when using the “:help” command.

The editor always opens in the command mode by default rather than in the second mode which is insert mode. In command mode, you can do tasks like navigate through texts; do search, replace, and or mark blocks as well as other editing tasks. Some of the commands let you shift to insert mode.

Below are some of the basic commands:

  • k – moves the cursor up;
  • j – moves the cursor down;
  • h – moves the cursor to the left;
  • l – moves the cursor to the right;
  • n p – this pastes text or texts “n” times;
  • Pressing SHIFT + G will move the prompt at the end of the document;
  • :recover – this command recovers a file after a sudden interruption;
  • yy – this command copies a chunk of text;
  • :1, $s/word/anotherword/g – this command will replace “word” with “anotherword” in the entire file.

Related Questions