How do I scroll and copy text from a terminal buffer in Vim?
<C-w>N
When using Vim's built-in :terminal, the buffer is in Terminal-Job mode by default, meaning all keystrokes go to the running shell.
415 results for "n N"
<C-w>N
When using Vim's built-in :terminal, the buffer is in Terminal-Job mode by default, meaning all keystrokes go to the running shell.
:let @a .= expand('%:t') . "\n"
Named registers are not just for yanks and deletes.
:let @a .= getline('.') . "\n"
Named registers are usually filled with yanks and deletes, but they are also plain variables you can edit with Vimscript.
<C-r>=substitute(getreg('+'), '\n\+', ', ', 'g')<CR>
When you paste from the system clipboard into code or config, multiline text often needs to be flattened first.
registers #registers #insert-mode #expression-register #text-processing
<C-w>n
n creates a new empty buffer and opens it in a horizontal split above the current window.
<C-\><C-n>
While works to leave insert or visual mode, it does not work in every situation — particularly in terminal mode (:terminal), where is consumed by the running
:%s/^\(.\+\)\n\1$/\1/
This substitute command detects pairs of identical adjacent lines and collapses them into one, using a back-reference to match the repeated content.
:undo {N}
:undo {N} lets you jump directly to the undo tree state after change number N was applied.
:g/\(.\+\)\n\1/d
The :g command with a backreference pattern can detect and delete consecutive duplicate lines in one pass.
:set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20
Neovim's guicursor option lets you assign a distinct cursor shape and style to each mode, providing immediate visual feedback about which mode you are in.
:tab sb N
How it works The :tab sb N command opens buffer number N in a brand new tab page.
:let @q = substitute(@q, '\n', '', 'g')
A common macro failure mode is accidentally hitting while recording.
n.
The n.
{N}@q
Prefix a macro invocation with a count to execute it up to N times in a single command.
{N}|
The command (pipe character) moves the cursor to a specific column number on the current line.
vim.keymap.set('n', '{key}', {fn}, { desc = '{description}' })
When defining keymaps with vim.
s/pattern/\r/
In Vim substitutions, \r in the replacement string inserts a line break, creating a new line.
:'<,'>!sort -t',' -k2 -n
Vim does not have a built-in multi-column sort, but you can leverage the external sort command to sort selected lines by any field.
editing #editing #sorting #ex-commands #external-commands #command-line
:b N
How it works Every buffer in Vim is assigned a unique number when it is opened.
:term then <C-w>N for normal mode
Vim 8+ and Neovim have a built-in terminal emulator that runs inside a buffer.
command-line #command-line #terminal #workflow #productivity