How do I jump to the beginning of a file in Vim?
gg
The gg command moves the cursor to the first line of the file.
25 results for "gg"
gg
The gg command moves the cursor to the first line of the file.
gg=G
The gg=G command re-indents every line in the current file according to Vim's indentation rules.
gg"aVGy
Go to the first line with gg, then visually select from there to the last line with VG, and yank into register a.
ggVG
While Vim doesn't have a built-in "entire buffer" text object, the ggVG sequence achieves it: go to the first line, enter line-wise visual mode, then select to
<C-w>N
When using Vim's built-in :terminal, the buffer is in Terminal-Job mode by default, meaning all keystrokes go to the running shell.
<C-v>jj$A;
Visual block mode normally selects a fixed-width column, which makes appending tricky when lines have different lengths.
<C-o> / <C-i>
Vim maintains a jumplist — a history of every "jump" you make (searches, marks, gg, G, %, etc.
==
The == command auto-indents the current line based on the surrounding context.
=
Pressing = in visual mode auto-indents the selected lines according to Vim's built-in indentation rules.
visual-mode #editing #visual-mode #indentation #formatting #productivity
:'<,'>retab!
The :retab! command converts between tabs and spaces based on your expandtab setting.
:let view=winsaveview() | {cmd} | call winrestview(view)
When writing Vimscript functions or mappings, commands like :substitute, gg, or :%normal will move the cursor and change the scroll position.
= (in visual mode)
After making a visual selection, pressing = applies Vim's auto-indent to every selected line at once.
=i{ or =ap
The = operator performs smart indentation based on Vim's filetype-aware indent rules.
:windo {cmd}
:windo {cmd} executes an Ex command in every window in the current tab page, cycling through each one and applying the command before returning focus to the ori
buffers-windows #windows #buffers #ex-commands #buffers-windows
G
The G command moves the cursor to the last line of the file.
:keepjumps
When writing scripts or running commands that move the cursor (like :g, :s, or :normal), Vim normally adds each cursor position to the jump list.
<C-o>{command}
While typing in insert mode, you sometimes need to do a quick normal-mode action — center the screen, jump to a mark, or delete a word backward.
42G
The 42G command jumps the cursor directly to line 42 in the current file.
<C-v>jj$A text<Esc>
Visual block mode combined with $A lets you append text to the end of multiple lines simultaneously, even when those lines have different lengths.
visual-mode #editing #visual-mode #block-mode #productivity #insert-mode
<C-o>
The (Ctrl+o) command jumps the cursor backward through the jump list, returning you to previous cursor positions.