How to set a mark and jump back to it in Vim
In Normal mode, press ma to set mark a at the cursor. 'a jumps back to that line, and `a to the exact spot. Any letter from a to z works. Capital marks, like mA, work across files.

Chorizo goes on the menu tomorrow at Byte Burrito. In menu.js it needs a price, a blurb, and the special at the top switched to it. You're on the pastor price, right where chorizo's price will go, and you want to do the other two jobs first and then land back here without looking for the line.
Chorizo on the menu
The cursor is on the pastor price, where chorizo's price goes last.
a here with ma. Go to the top with gg and make chorizo the special: ci', chorizo, then Escmenu.jsThis editor needs a keyboard. Read on, and play it at your computer.
Go back to the exact spot with a backtick
'a lands at the start of the marked line's text. The backtick version, `a, goes back to the line and the column you marked, which is what you want when you left off in the middle of a line.
Each lowercase letter is a separate mark, so mb leaves a where it is. Setting a letter again moves that mark to the cursor.
Grilled pineapple
The pastor blurb should say grilled pineapple. The cursor is already on pineapple when you remember that pastor is today's special.
b on pineapple with mb. Go to the top with gg and change the special to pastor with ci', pastor and Escmenu.jsThis editor needs a keyboard. Read on, and play it at your computer.
Vim also keeps one mark for you. `` goes back to where you were before your last jump, and '' to that line. How to jump back covers those and Ctrl-o. Your own marks stay where you put them, however many jumps you make after.
Delete or copy everything up to a mark
A mark is also a place to aim an operator at. d'a deletes every line from the cursor's line to the marked one, both included, and y'a copies them. The mark can be above the cursor or below it. This is how you remove a block too long to count: set ma on its first line, scroll or search down to its last, and press d'a.
export const DRINKS = { horchata: 3, // summer only agua_fresca: 3, limonada: 3, // all year jarritos: 4,};export const DRINKS = { horchata: 3, // all year jarritos: 4,};With the backtick, the operator works on characters instead of whole lines. d`a deletes from the mark to the cursor, and the character at whichever of the two comes later stays.
Lines or characters
The cursor is on the p of price, in Normal mode. You set mark a with ma, go to the end of the line with $, then press d`a. What does the line say now?
Jump to a mark in another file
Lowercase marks belong to their file. Each file has its own a to z, so 'a in another file goes to that file's mark a, or says E20: Mark not set.
Capital marks, mA to mZ, remember the file as well, and there's only one of each. Set mV in your vimrc and 'V opens it again from wherever you are, at the marked line.
Vim and Neovim remember your marks after you quit: every capital mark, and the lowercase marks of the last hundred files you edited.
List and delete your marks
:marks lists every mark with its line, its column and the text on that line, or the file name for a capital mark in another file. The marks Vim sets for you are in the list too. :marks aB lists only those two.
:delmarks a deletes mark a, :delmarks a-d deletes a to d, and :delmarks! deletes every lowercase mark in the current file. Capitals go by name, as in :delmarks A. A deleted mark stays deleted the next time you open the file.
Which mark keys?
| Keys | Does |
|---|---|
| ma | sets mark a at the cursor (any letter from a to z) |
| 'a | goes to the line of mark a, at the start of its text |
| `a | goes to the exact line and column of mark a |
| mA / 'A | a capital mark: it remembers the file, and works from any file |
| d'a / y'a | deletes / copies the lines from the cursor's line to mark a |
| d`a / y`a | deletes / copies the characters from the cursor to mark a |
:'a,'bd | runs an Ex command (here, delete) on the lines from mark a to mark b |
| `` / '' | goes back to where you were before the last jump |
| `< / `> | goes to the start / end of the last Visual selection |
:marks | lists the marks, with line, column and text |
:delmarks a / :delmarks a-d / :delmarks! | deletes one mark / a range / every lowercase mark in the file |