How do I execute a single normal mode command inside a Neovim terminal buffer without fully leaving terminal mode?
Answer
<C-\><C-o>
Explanation
In a Neovim terminal buffer, <C-\><C-n> exits to normal mode permanently. But sometimes you only want to run one normal mode command and then immediately return to the terminal — without having to press i or a to re-enter it. <C-\><C-o> does exactly that: it executes a single normal mode command and drops back into terminal mode.
How it works
- While in a terminal buffer (insert/terminal mode), press
<C-\><C-o> - You are briefly placed in normal mode for one command
- After the command completes, you automatically return to terminal mode
- This mirrors
<C-o>behavior in regular insert mode, applied to terminal mode
Example
You are typing in a terminal buffer and want to yank the current line to a register without interrupting your shell session:
<C-\><C-o>yy → yank current line, then return to terminal mode
<C-\><C-o>"ayy → yank current line to register a, return to terminal mode
<C-\><C-o>G → jump to end of terminal output, return to terminal mode
Compare:
<C-\><C-n>— exit to normal mode (you must pressiorato resume the shell)<C-\><C-o>— run one command, return automatically
Tips
- Use
<C-\><C-o>Gto scroll to the bottom of terminal output and come back - Use
<C-\><C-o>"*y}to yank a paragraph of output to the clipboard - This shortcut is only available in Neovim terminal buffers, not Vim's
:terminal