Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to page-up / page-down through vim terminal

Tags:

linux

vim

neovim

I am new user to Vim and I want to use vim's embedded terminal (called by :term). Unfortunately, I cannot use this terminal as I want to. The Shift + PageUp / Shift + PageDown duo (to move up and down through logs) does not work. I tried to solve the issue, with found mapping tnoremap <CTRL-V><CTRL-PAGEUP> : tabp<CR>, but this one does not work.

like image 926
BlackHawk3 Avatar asked Oct 01 '18 11:10

BlackHawk3


Video Answer


1 Answers

The best way that I've found to do this is to start a tmux session within the Vim terminal, then scroll in tmux copy mode. I can't necessarily give any key-bindings for this because it really depends on your tmux setup. You can make tmux use the Vim-like <C-u> and <C-d> (up and down half a page) by adding the following to your .tmux.conf:

set -gw mode-keys vi

For that matter, why not use vi mode in bash?

set -o vi

To actually scroll in tmux then, you need to use your tmux prefix key (defaults to <C-b>) followed by [ to put it in "copy mode".


Here is an example of my Vim/Tmux terminal. Note that at the end I turn off the status bar by typing <C-b> (the default tmux prefix hotkey) followed by : (put tmux in command mode). Finally enter the command set -g status off.

enter image description here


However, I normally only do this if I am using GVim or MacVim, but for the most part I run Vim inside of a tmux session in a terminal which lets me get all of this for free.

like image 133
JakeD Avatar answered Sep 22 '22 04:09

JakeD