With :vsplit | te <command>
I run a command in the terminal emulator of neovim in a vertical split. But how can I scroll its output? When I press a key, the split window is closed again.
For illustrational purpose, lets take the command :vsplit | te ls -lah /usr/lib/
which produces a long output in the split window. How can I now scroll up in this split window in order to see a bit more of the output? I found out that it is possible with the mouse-wheel when you use set mouse=a
, but I don't like to use the mouse.
According to the Neovim documentation:
Terminal-mode has its own |:tnoremap| namespace for mappings, this can be used to automate any terminal interaction.
Therefore, you can map whatever keys or combinations you want.
Additionally, you can scroll the terminal window by using PgUp and PgDown. On a full keyboard those keys should be available, on a laptop one it's often available through fnā and fnā.
Update:
Some additional configuration options regarding Terminal-mode.
if has("nvim")
" Make escape work in the Neovim terminal.
tnoremap <Esc> <C-\><C-n>
" Make navigation into and out of Neovim terminal splits nicer.
tnoremap <C-h> <C-\><C-N><C-w>h
tnoremap <C-j> <C-\><C-N><C-w>j
tnoremap <C-k> <C-\><C-N><C-w>k
tnoremap <C-l> <C-\><C-N><C-w>l
" I like relative numbering when in normal mode.
autocmd TermOpen * setlocal conceallevel=0 colorcolumn=0 relativenumber
" Prefer Neovim terminal insert mode to normal mode.
autocmd BufEnter term://* startinsert
endif