• Modern UX

    Edit and navigate faster in the terminal with Warp's IDE-like input editor.

  • Warp AI

    AI suggests what commands to run and learns from your documentation.

  • Agent Mode

    Delegate tasks to AI and use natural language on the command line.

  • Warp Drive

    Save and share interactive notebooks, workflows, and environment variables.

  • All Features

Select all in Vim / Vi

Thumbnail for Glory KimThumbnail for Glory KimThumbnail for Glory KimThumbnail for Glory Kim
Glory Kim

Glory Kim

Software Engineer, Loom

Published: 8/13/2024

About Terminus

To perform the command traditionally known as “ctrl + a” to select all in Vim, do ggVG.

Breaking it down:

1. Check that you are in normal mode - hit the ESC key.

2. Move the cursor to the beginning of the file - gg.

3. Enter visual mode which lets you see the highlight portions - V

Pressing V enters line visual mode while pressing lower case v will enter character visual mode. Being in v mode will cause the below command to highlight until the first character of the last line in the file.

4. Select from the current cursor position to the end of the file - G

At this point, you can scroll up and down or use Vim commands to de-select lines.

Thumbnail for Thumbnail for Thumbnail for Thumbnail for

Vim copy all lines

After performing the select all sequence above, you can use this command to copy the whole entire file: y. This will yank and copy the selected lines.

Vim copy all to clipboard

Using yank alone only copies the portion to the default register (i.e. Vim). It won’t copy to the clipboard. So if you wanted to copy the selected code to use outside the terminal you’ll need to use gg"*yG

  • Move the cursor to the beginning of the file - gg
  • Copy it to the clipboard from current position - "*y
  • Move the cursor to the end of the file - G

Vim paste all

In order to paste what you’ve copied, you can hit p to paste after the cursor and P to paste before the cursor.

Read more about copy/pasting text in Vim.

Vim delete all lines

To clear all the lines of a file: :%d

  • Go to normal mode - ESC
  • Enter command mode - :
  • Select All - %
  • Delete - d

Learn more about deleting lines in Vim.

Make a mistake? If you want to undo an accidental deletion, you can use the u command (:u) to undo in Vim, and the lines that were deleted will show up again.

Written by

Thumbnail for Glory KimThumbnail for Glory KimThumbnail for Glory KimThumbnail for Glory Kim
Glory Kim

Glory Kim

Software Engineer, Loom

Filed Under

Related Articles

Vim Find And Replace

You can use either the substitute command or the slash and dot method to search for patterns and replace with different values.

VimVi
Thumbnail for Glory KimThumbnail for Glory KimThumbnail for Glory KimThumbnail for Glory Kim
Glory Kim

Vim Modes

Learn about seven of Vim’s modes

VimVi
Thumbnail for Razvan LudosanuThumbnail for Razvan LudosanuThumbnail for Razvan LudosanuThumbnail for Razvan Ludosanu
Razvan Ludosanu

Vim / Vi Page Up and Down Controls

Quick reference for Vim's page up and down controls

VimVi
Thumbnail for Glory KimThumbnail for Glory KimThumbnail for Glory KimThumbnail for Glory Kim
Glory Kim

Copy & Paste in Vim / Vi

Copy (Yank), Paste (Put) and Cut (Delete) in Vim

VimVi
Thumbnail for Jessica WangThumbnail for Jessica WangThumbnail for Jessica WangThumbnail for Jessica Wang
Jessica Wang

Undo & Redo in Vim / Vi

Keyboard shortcuts and summary of how Vim tracks changes

VimVi
Thumbnail for Jessica WangThumbnail for Jessica WangThumbnail for Jessica WangThumbnail for Jessica Wang
Jessica Wang

Show & Hide Line Numbers in Vim / Vi

Toggle absolute and relative line numbers

VimVi
Thumbnail for Amber ChenThumbnail for Amber ChenThumbnail for Amber ChenThumbnail for Amber Chen
Amber Chen

Searching in Vim

Search forward, backward, case insensitive, and more

VimVi
Thumbnail for Neeran GulThumbnail for Neeran GulThumbnail for Neeran GulThumbnail for Neeran Gul
Neeran Gul

Go To End of File in Vim / Vi

Select and delete to the end of a file in Vim

VimVi
Thumbnail for Preston Tunnell WilsonThumbnail for Preston Tunnell WilsonThumbnail for Preston Tunnell WilsonThumbnail for Preston Tunnell Wilson
Preston Tunnell Wilson

How to delete lines in Vim / Vi

The best answer depends on which mode you use

VimVi
Thumbnail for Andrew CarlsonThumbnail for Andrew CarlsonThumbnail for Andrew CarlsonThumbnail for Andrew Carlson
Andrew Carlson

Trusted by hundreds of thousands of professional developers

Download Warp to get started

Download for Mac
Request demo
Thumbnail for nullThumbnail for nullThumbnail for nullThumbnail for null