6

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.

BlackHawk3
  • 339
  • 4
  • 10
  • 2
    Exit insert mode then use the usual Vim commands (e.g. Ctrl-B for page up). `:help scrolling` – Amadan Oct 01 '18 at 12:22
  • While I am in `TERMINAL` mode (when I switch from pane of text in `NORMAL` mode to vim terminal) Ctrl-B does not work. – BlackHawk3 Oct 01 '18 at 12:51
  • 3
    I meant, exit terminal job mode (Ctrl-W N) into terminal normal mode. In terminal job mode, cursor and scrolling is controlled by the job, and you cannot scroll.`:help Terminal-Job`: "When the job is running the contents of the terminal is under control of the job. That includes the cursor position." `:help Terminal-Normal`: "When the job outputs lines in the terminal, such that the contents scrolls off the top, those lines are remembered and can be seen in Terminal-Normal mode." – Amadan Oct 01 '18 at 12:58
  • Is `shift`+`PageUp` the scroll binding of your terminal? What are you exactly looking at in the terminal? logs? Wouldn't it be better to open them in vim? – Doktor OSwaldo Oct 01 '18 at 14:33

1 Answers1

3

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.

JakeD
  • 2,788
  • 2
  • 20
  • 29