How do I make Vim open new splits below and to the right instead of above and left?
:set splitbelow splitright
How it works By default, Vim opens horizontal splits (:split or :sp) above the current window and vertical splits (:vsplit or :vsp) to the left.
category:
config
tags:
#windows
#navigation
How do I use a Vim expression as the replacement string in a :s substitution?
Vim's :s command normally replaces matches with a literal string.
category:
command-line
tags:
#search
#editing
#ex-commands
#command-line
#registers
How do I edit a macro in-place using Vimscript without re-recording it?
:let @a = substitute(@a, "old", "new", "g")
When a recorded macro has a typo or wrong command buried inside it, you don't have to re-record the entire thing.
category:
macros
tags:
#macros
#registers
#vimscript
#editing
How do I use PCRE-style regex in Vim without escaping every special character?
Vim's default regex mode ("magic") requires backslashes before many special characters: \(, \ , \+, \{.
category:
search
tags:
#search
#regex
#patterns
#normal-mode
How do I jump to the beginning of the previous word?
The b command moves the cursor backward to the beginning of the previous word.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I search for a string containing special regex characters like dots or asterisks without escaping them?
Vim's default search mode gives special meaning to characters like .
category:
search
tags:
#search
#regex
#normal-mode
How do I sort lines based on a specific field or column rather than the beginning of each line?
The :sort /pattern/ command sorts lines by the text that appears after the first match of a pattern, not from the start of each line.
category:
command-line
tags:
#ex-commands
#editing
#visual-mode
How do I make Vim always open new splits below and to the right instead of above and to the left?
:set splitright splitbelow
By default, :split opens a new window above the current one and :vsplit opens to the left — the opposite of most modern IDEs and editors.
category:
config
tags:
#config
#windows
#splits
#buffers-windows
How do I programmatically populate the quickfix list from Vimscript?
setqflist() lets you build the quickfix list from a Vimscript list of dictionaries rather than relying on compiler output or :vimgrep.
category:
command-line
tags:
#ex-commands
#buffers
How do I quickly resize the current window to exactly N lines tall in Vim?
The z{N} command sets the current window's height to exactly N lines and simultaneously positions the current line at the top of the window.
category:
buffers-windows
tags:
#buffers-windows
#windows
#navigation
How do I define or fix a macro using Vimscript instead of re-recording it?
Macros in Vim are just text stored in named registers.
category:
macros
tags:
#macros
#registers
#ex-commands
How do I define key mappings in Neovim using Lua instead of the old Vimscript API?
vim.
category:
config
tags:
#config
#macros
#normal-mode
How do I write a Vim regex lookahead that doesn't consume a capture group slot?
Vim's lookahead assertion \@= confirms that the current position is followed by a pattern — without including those characters in the match.
category:
search
tags:
#search
#regex
#lookahead
#patterns
#normal-mode
How do I edit the contents of a macro using Vimscript string functions without re-recording it?
:let @q = substitute(@q, 'from', 'to', 'g')
Macros are stored as plain text in named registers, so you can manipulate them with any Vimscript string function.
category:
macros
tags:
#macros
#registers
#ex-commands
How do I edit a complex Ex command in a full editing window?
q: or <C-f> from : prompt
The command-line window (q:) opens a full Vim buffer containing your Ex command history.
category:
command-line
tags:
#command-line
#history
#editing
#workflow
How do I undo all changes made since the last time I saved the file in a single step?
The :earlier {count}f command navigates Vim's undo tree to the state of the buffer at the time of the last (or Nth) file write.
category:
editing
tags:
#undo-redo
#ex-commands
#editing
How do I delete everything typed on the current line without leaving insert mode?
Pressing while in insert mode deletes all characters entered since you last entered insert mode on the current line.
category:
editing
tags:
#insert-mode
#editing
#delete
#normal-mode
How do I undo or redo to a specific point in time using time-based undo navigation?
:earlier {time} and :later {time}
Vim's :earlier and :later commands let you navigate the undo history by elapsed time rather than by edit count.
category:
command-line
tags:
#undo-redo
#ex-commands
#editing
How do I make two windows scroll together in sync?
The scrollbind option locks the scrolling of two or more windows together so they scroll in unison.
category:
navigation
tags:
#navigation
#scrolling
#windows
How do I open the command-line window while typing a command on the : prompt?
<C-f> (from command-line mode)
When you are partway through typing a long or complex Ex command on the : prompt, you can press to open the command-line window.
category:
search
tags:
#command-line
#ex-commands
#editing
#normal-mode