How do I paste the unnamed register after transforming it to uppercase?
Registers in Vim are not only for raw replay; you can treat them as string data and transform them at paste time.
category:
registers
tags:
#registers
#expression-register
#editing
#vimscript
How do I remove accidental Enter keystrokes from a recorded macro?
:let @q = substitute(@q, '\n', '', 'g')
A common macro failure mode is accidentally hitting while recording.
category:
macros
tags:
#macros
#registers
#debugging
#vimscript
How do I remove the last recorded keystroke from a register or macro in Vim?
Macros and named registers are just strings, so you can surgically edit them instead of re-recording from scratch.
category:
registers
tags:
#registers
#macros
#vimscript
#editing
How do I edit an existing macro by modifying its register text instead of rerecording it?
:let @q = substitute(@q, '\n$', 'A;<Esc>\n', '')
Rerecording a long macro for one tiny change is slow and error-prone.
category:
macros
tags:
#macros
#registers
#automation
#vimscript
How do I inspect a register as a list of lines in Vimscript?
For advanced register debugging and macro tooling, plain getreg('a') is often not enough.
category:
registers
tags:
#registers
#vimscript
#debugging
#automation
How do I copy one register to another while preserving its exact register type?
:call setreg('b', getreg('a'), getregtype('a'))
Plain register copies like :let @b = @a move text, but they can lose important metadata about register type.
category:
registers
tags:
#registers
#advanced
#vimscript
#editing
How do I programmatically create a blockwise register with setreg()?
:call setreg('a', "foo\nbar", 'b')
Most register examples focus on interactive yanks, but setreg() lets you construct registers programmatically, including their type.
category:
registers
tags:
#registers
#vimscript
#automation
#editing
How do I zero-pad every number in a line using a Vim substitute expression?
:s/\v\d+/\=printf('%04d', submatch(0))/g
Substitution expressions let Vim compute each replacement dynamically, which is ideal when plain capture groups are too limited.
category:
editing
tags:
#editing
#substitution
#regex
#vimscript
How do I append the current line to a register from command line without using yank?
:let @a .= getline('.') . "\n"
Named registers are usually filled with yanks and deletes, but they are also plain variables you can edit with Vimscript.
category:
registers
tags:
#registers
#command-line
#vimscript
#editing
How do I call a Lua function or evaluate a Lua expression from within Vimscript in Neovim?
luaeval('lua_expression')
When you have existing Vimscript code that needs to reach into Neovim's Lua ecosystem, luaeval() is the bridge.
category:
config
tags:
#neovim
#config
#vimscript
#lua
How do I encode and decode JSON data in Vimscript for configuration and plugin development?
Vim 8.
category:
config
tags:
#config
#vimscript
#ex-commands
How do I use glob() in Vimscript to get a list of files matching a wildcard pattern?
The glob() built-in function expands a wildcard pattern into a list of matching filesystem paths, entirely within Vimscript.
category:
config
tags:
#config
#vimscript
#files
#ex-commands
How do I create a mapping that calls a script-local function in Vim without namespace collisions?
(Script ID) is a Vimscript token that expands to a unique, per-script prefix at runtime.
category:
config
tags:
#config
#vimscript
#mappings
#functions
#normal-mode
How do I execute Lua code directly from the Neovim command line without writing a script file?
Neovim's :lua command lets you run arbitrary Lua code inline from the command line.
category:
command-line
tags:
#command-line
#lua
#neovim
#vimscript
#advanced
How do I programmatically read and write Vim register contents including their type from Vimscript?
The setreg(reg, value, type) and getreg(reg, 1, 1) functions give you full programmatic control over registers, including their type (characterwise, linewise, o
category:
registers
tags:
#registers
#vimscript
#macros
#ex-commands
How do I run Lua code in the context of a specific buffer without switching to it in Neovim?
vim.
category:
config
tags:
#ex-commands
#vimscript
#buffers
#config
How do I register a Lua callback that fires before every keystroke to react to keyboard input?
vim.
category:
config
tags:
#ex-commands
#vimscript
#config
#macros
How do I safely run Neovim API calls from inside a fast callback or loop without causing errors?
vim.
category:
config
tags:
#ex-commands
#vimscript
#config
#completion
How do I step through a Vimscript command or function to debug it interactively?
The :debug command prefix puts Vim into its built-in interactive debugger before executing the given command.
category:
command-line
tags:
#ex-commands
#debugging
#command-line
#vimscript
How do I check if a specific Vim feature or capability is available before using it in my vimrc?
The has('feature') function returns 1 if the specified feature is available in the current Vim/Neovim instance, 0 otherwise.
category:
config
tags:
#config
#vimscript
#portability