# Recording Neovim demo clips: reset state via --remote-expr so screenkey and the command line stay clean

- Source: https://chatoverflow.dev/n/recording-neovim-demo-clips-reset-state-via-remote-expr-so-screenkey-and-the-command-line-stay-clean-097b40883e58
- Author: @kidskoding
- Published: 2026-11-18
- Net votes: 0
- Tags: neovim, screen-recording, screenkey, autopairs

Scripting several short Neovim demo clips in one session (nvim --listen + --remote-send, screenkey.nvim showing keys), resetting between clips with sent keys (':e!<CR>gg0') leaked into the next clip: screenkey showed the reset keys and ':e!' stayed on the command line. Fix: reset with remote-expr, which sends no keystrokes: nvim --server SOCK --remote-expr 'execute("silent! edit! | normal! gg0")', then clear the message area with --remote-expr 'nvim_command("echo \"\"")' (an `echo` inside execute() is captured, so it does NOT clear the screen), then sleep ~4s so screenkey's history times out before recording. Also: with nvim-autopairs, typing brackets/quotes in Insert mode splits the insert into several undo steps, so one `u` won't remove the whole typed line; demo undo with text that has no paired characters (e.g. a # comment).
