How do I cycle through my jump history in Vim?
<C-o> and <C-i>
Vim maintains a jump list of positions you have visited.
142 results for ":marks"
<C-o> and <C-i>
Vim maintains a jump list of positions you have visited.
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
Vim remembers the last cursor position for every file you edit (stored in the viminfo or shada file), but by default it opens files at line 1.
:call setreg('a', "foo\nbar", 'b')
Most register examples focus on interactive yanks, but setreg() lets you construct registers programmatically, including their type.
:%s/\v<(\w)(\w*)>/\u\1\L\2/g
When you need to normalize casing across headings, labels, or generated docs, editing words one by one is tedious.
:keepjumps normal! gg=G
Bulk formatting commands are common in cleanup sessions, but they often leave side effects in your navigation history.
/\%>20l\%<40lTODO
Vim's search engine can constrain matches by line number, which is useful when you want to scan a known section without touching the rest of the buffer.
:'>,'<normal @q
Running a macro over a range usually goes top to bottom, but that can break when the macro inserts or deletes lines.
macros #macros #ex-commands #visual-mode #normal-mode #refactoring
[[
The [[ and ]] commands navigate between top-level code blocks — specifically, lines where { appears in column 1.
:set diffopt+=algorithm:patience,indent-heuristic,linematch:60
Default diff settings can produce noisy hunks when code is moved, re-indented, or lightly refactored.
:g/^/t.
The command :g/^/t.
:set list listchars=tab:>-,trail:~,eol:$
Enabling list mode makes Vim render normally invisible characters using configurable symbols defined in listchars.
:history
:history displays a numbered list of your recently entered Ex commands, giving you a full audit of what you have run in the current session (and across sessions
:keepjumps keeppatterns %s/\s\+$//e<CR>
Bulk whitespace cleanup is common, but a plain substitution can leave side effects: your last search pattern changes and jump navigation gets noisy.
:[range]center / :[range]right / :[range]left
Vim has built-in Ex commands for text alignment: :center, :right, and :left.
:'<,'>w {filename}
After making a visual selection, you can write only those lines to a new file using :'w {filename}.
:windo diffthis<CR>
If you already have several related files open in splits, enabling diff mode one window at a time is slow and error-prone.
buffers-windows #buffers-windows #diff #windows #ex-commands
:set fileformat=unix
When you open a Windows file in Vim on a Unix system, you may see ^M at the end of every line — that's the carriage return (\r) from CRLF line endings.
:diffthis
You often have two files open side by side and want to compare them without leaving Vim or launching vimdiff.
<C-x>s
When spell checking is enabled (:set spell), s in insert mode opens a popup menu of suggested corrections for the most recently flagged misspelled word — with
zG
zG marks the word under the cursor as correctly spelled in Vim's internal word list, which exists only for the current session.