How to go to the end of a file in Vim
In Normal mode, press G to go to the last line of the file and gg to go to the first. As commands, :$ and :1 with ↵ do the same.
Finish the checklist
Add a last item at the bottom with G and o, then go to the top with gg and add to the title with A.
This editor needs a keyboard. Read on, and play it at your computer.
| Keys | What it does |
|---|---|
| G | Go to the last line. |
| gg | Go to the first line. |
:$ ↵ / :1 ↵ | The same, typed as commands: $ means the last line. |
| G$ | Go to the very last character of the file. |
| Go / ggO | Open a new line below the last line / above the first, in Insert mode. |
| dG | Delete from this line to the end of the file. |
| dgg | Delete from this line to the top. |
| yG / ygg | Copy from this line to the end / to the top. |
| ggdG | Delete every line in the file (:%d ↵ does the same). |
| gg=G | Re-indent the whole file. |
## Installnpm install## Old notesMoved to the wiki in March.See the wiki for the link.## Installnpm installG and gg as motions
G and gg are motions, so they work after any operator, and they always take whole lines. dG deletes from the line you are on to the last line, yG copies the same lines, and >G indents them. Put gg in front and the operator covers the whole file: ggyG copies everything, ggdG empties the file. The command-line versions are :%y and :%d, where % means every line.
Both are also jumps, so Vim remembers where you were. After a quick look at the end of the file with G, two backticks, ``, bring you back to the exact spot you left.