Vim Command to Copy All Text


I like to use "linewise-visual-mode" for working with blocks of text. It let's me see what I'm doing and grab exactly the section I need.

Note, "linewise-visual-mode" is entered with the uppercase "V" command. A lowercase "v" will put you in "visual-mode" which allows you to select character-by-character rather than line-by-line.

Below, you'll see how to copy all text without selecting any text at all...


The Setup

gg move to the top of the file

Change Modes

V enter linewise-visual-mode

Two & Done

G move to bottom of file

y yank selected text

Vim Command to Copy All Text in Normal Mode

It's very common to accomplish a task in Vim using 2 commands - a movement and an operator. Above, we used a visual mode to select text by moving over it and then applying an operator to the selected text.

However, if we issue the operator first, it will be applied to the text we then move over...


The Setup

gg move to the top of the file

Two & Done

y yank the text I’m about to move over

G move to bottom of file