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.
2125 results for "i" a""
gg
The gg command moves the cursor to the first line of the file.
set sidescrolloff
set sidescrolloff={n} keeps at least n columns of context to the left and right of the cursor when long lines cause the view to scroll horizontally.
:'<,'>center / :'<,'>right / :'<,'>left
Vim has built-in Ex commands to align text within a specified width: :center, :right, and :left.
<C-r>{register}
Pressing followed by a register name in insert mode inserts the contents of that register at the cursor position without leaving insert mode.
:nnoremap <expr> {key} {expression}
The argument to any map command (:nmap, :inoremap, etc.
config #config #macros #insert-mode #normal-mode #ex-commands
<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.
zfap
Combining the fold-creation operator zf with the ap (around paragraph) text object gives you a quick way to collapse any paragraph into a single fold line.
set foldlevelstart=N
When Vim opens a file with folds enabled, it uses the foldlevelstart option to decide how many fold levels to open automatically.
r{char}
The r{char} command replaces the character under the cursor with {char} without ever entering insert mode.
:set operatorfunc=MyFunc<CR>g@{motion}
Vim's operatorfunc and g@ let you define custom operators that accept any motion or text object, just like built-in operators d, c, and y.
:compiler {name}
The :compiler command loads a compiler plugin from Vim's runtime path, setting both makeprg (the build command) and errorformat (the error parsing pattern) in o
/pattern\c
Vim's \c and \C atoms let you override the global ignorecase and smartcase settings on a per-search basis.
:set nrformats+=hex,bin
By default, Vim's and only increment and decrement decimal numbers.
[/ and ]/
Vim provides two motions for navigating C-style block comments (/ .
:set makeprg=
The makeprg option defines the command that :make runs.
:leftabove sbuffer #
If you often compare your current file against the previously visited buffer, replacing the current window is disruptive.
:/start/,/end/command
Vim allows pattern-based ranges in Ex commands, letting you operate on lines between two search matches.
q?
Vim provides three command-line history windows accessible from normal mode: q: for Ex commands, q/ for forward searches, and q? for backward searches.
:%s/\(prefix\)\@<=target/replacement/g
Vim's \@<= is a zero-width look-behind assertion.
:set completeopt=menuone,noinsert,noselect
When completion inserts text too early, you lose control over what gets committed and where undo breakpoints land.