• 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

Vim Go To End/Start of Line

Thumbnail for Glory KimGlory Kim

Glory Kim

Software Engineer, Loom

Published: 1/31/2024

About Terminus

Use the ESC key to enter normal mode in vim:

  • Press $ to move the cursor to the end of the line
  • Press g_ to move the cursor to the last non-whitespace character

Thumbnail for

On the left is the result after typing $ to go to the end of the line, and on the right is the result after g_ to go to the last non-whitespace character.

Insert at the end of a line with Vim

To edit the end of the line, you can press A to jump to the last character and switch to insert mode.

Go to the beginning of a line with Vim

In normal mode:

  • Press 0 to move the cursor to the start of the line
  • Press ^ or _ to move to the first non-whitespace character in the line

To edit the beginning of the line, you can press I (capital i) to go to the first non-whitespace character and switch to insert mode.

Once you have navigated to the desired position, you can use other Vim commands such as: 

  • j to move the cursor to the next line
  • x to delete the character under the cursor
  • dG to delete everything after the cursor

Note: The commands above are cursor-specific, meaning that the position of your cursor is essential and will affect the command. For those types of commands, navigating to either the end or the beginning of the line before executing those commands is helpful.

However, some commands, like those below, are line-specific and do not require the cursor to be at a specific position on the line:

  • o creates a new line below the current line and enters insert mode
  • O creates a new line above the current line and enters insert mode
  • J appends the next line next to the current line
  • dd deletes the current line
  • yy yanks (copy) the current line

To keep reading about navigating in Vim, check out these tips on going to the end of the file and copy and pasting.

Written by

Thumbnail for Glory KimGlory 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 KimGlory Kim

Vim Modes

Learn about seven of Vim’s modes

VimVi
Thumbnail for Razvan LudosanuRazvan Ludosanu

Go To Top of File in Vim

Learn how to jump the top of the file in Vim, then navigate, search, highlight, and delete.

Vim
Thumbnail for Glory KimGlory Kim

Go To Line In Vim

Variety of approaches to go to lines

Vim
Thumbnail for Preston Tunnell WilsonPreston Tunnell Wilson

Vim / Vi Page Up and Down Controls

Quick reference for Vim's page up and down controls

VimVi
Thumbnail for Glory KimGlory Kim

Copy & Paste in Vim / Vi

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

VimVi
Thumbnail for Jessica WangJessica Wang

Undo & Redo in Vim / Vi

Keyboard shortcuts and summary of how Vim tracks changes

VimVi
Thumbnail for Jessica WangJessica Wang

Show & Hide Line Numbers in Vim / Vi

Toggle absolute and relative line numbers

VimVi
Thumbnail for Amber ChenAmber Chen

Select all in Vim / Vi

Select all and copy, paste, or delete the contents

VimVi
Thumbnail for Glory KimGlory Kim

Searching in Vim

Search forward, backward, case insensitive, and more

VimVi
Thumbnail for Neeran GulNeeran 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 WilsonPreston Tunnell Wilson

How to delete lines in Vim / Vi

The best answer depends on which mode you use

VimVi
Thumbnail for Andrew CarlsonAndrew Carlson

Trusted by hundreds of thousands of professional developers

Download Warp to get started

Download for Mac
Thumbnail for null