How do I use a Vimscript function to control how the gq operator formats text?
:set formatexpr=MyFormat()
The formatexpr option lets you replace Vim's built-in line-breaking logic for the gq operator with your own Vimscript expression or function.
2277 results for "@a"
:set formatexpr=MyFormat()
The formatexpr option lets you replace Vim's built-in line-breaking logic for the gq operator with your own Vimscript expression or function.
ct{char}
The ct{char} command deletes everything from the cursor up to (but not including) the specified character and drops you into insert mode.
editing #editing #motions #normal-mode #text-objects #productivity
gnn / grn / grm
nvim-treesitter's incremental selection module lets you grow and shrink your visual selection one syntax node at a time.
:keeppattern s/old/new/g
When you run a :s or :g command, Vim updates the search register (@/) with the pattern you used.
:set winbar=%f
Neovim 0.
:%s/pattern/\=@0/g
The \=@0 replacement expression inserts the contents of register 0 (last yank) as the replacement text.
vim.lsp.config('server', { cmd = {...}, root_markers = {...}, filetypes = {...} })
Neovim 0.
:m +1
The :move command (abbreviated :m) relocates lines to a new position in the buffer without touching any registers.
:call setloclist(0, [], 'r', {'title': 'TODO current file', 'lines': systemlist('rg --vimgrep TODO ' . shellescape(expand('%:p'))), 'efm': '%f:%l:%c:%m'})
For focused review work, a window-local location list is often better than global quickfix.
buffers-windows #buffers #windows #location-list #search #quickfix
o (in Visual mode)
When you make a Visual selection in Vim, the cursor sits at one end while the other end is anchored.
$
The $ command moves the cursor to the last character of the current line.
:center / :left / :right
Vim has three built-in Ex commands for aligning text without any plugins: :left, :center, and :right.
<C-y>,
The emmet-vim plugin brings the full power of Emmet (formerly Zen Coding) to Vim, letting you type a short CSS-like abbreviation and expand it into a complete H
%:e
Vim exposes the current filename as % in Ex commands, and you can apply modifiers to extract specific parts of the path.
/\zs and \ze
The \zs and \ze atoms let you define where the actual match starts and ends within a larger pattern.
\u / \l / \U / \L (in :s replacement)
Vim's :substitute replacement string supports case-conversion modifiers that let you uppercase or lowercase matched text without writing a separate command.
:/BEGIN/,/END/-1s/\s\+$//
When you need to clean or refactor block-like regions, Ex ranges can target lines between two search patterns without selecting text manually.
command-line #command-line #ex-commands #ranges #search #editing
vaB
The aB text object (around Block) selects everything from the matching { to the closing } — including the braces themselves.
:next
When Vim is opened with multiple files (e.
command-line #buffers-windows #ex-commands #navigation #editing
saghen/blink.cmp
blink.