Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to scroll faster in vim

Tags:

Scrolling while keeping j or k pressed is too slow. Doing 10j multiple times isn't ideal either.

How can I go faster while keeping a key pressed ? I'm using vim for vscode but I imagine the solution probably applies there too.

like image 362
Lev Avatar asked Jan 02 '19 13:01

Lev


People also ask

How do I scroll down in Vim?

You can make Vim scroll the text using the shifted up/down arrows by mapping Shift-Up to Ctrl-Y and Shift-Down to Ctrl-E. Shift-Down will then scroll down (like moving a scroll-bar down, or like moving a cursor at the bottom of a window down), and Shift-Up will then scroll up (like moving a scroll-bar up, etc).

How do I move up and down in Vim?

In normal mode or in insert mode, press Alt-j to move the current line down, or press Alt-k to move the current line up. After visually selecting a block of lines (for example, by pressing V then moving the cursor down), press Alt-j to move the whole block down, or press Alt-k to move the block up.

How do I go down half page in Vim?

Press the ESC key to change normal mode. Press the CTRL+u key in order to 1/2 page down or 1/2 move forward.


2 Answers

If you are looking to speed up the time to get to a specific spot, having many pages. These commands support to keep the keys press if needed to increase speed:

ctrl + f (page down)

ctrl + b (page up)

ctrl + d (scroll window downwards, normally half a a screen)

ctrl + u (scroll window upwards, normally half a a screen)

like image 87
Toolbox Avatar answered Sep 19 '22 02:09

Toolbox


I believe you're looking for a better way to navigate between say code blocks or similar sections without having to do recursive j's or k's. These are my personal favorites :

  • Scrolling through screen with the cursor staying on the same line/present line by Ctrl+y and Ctrl+e
  • Moving between paragraphs. Very useful for moving between code blocks(assuming no newline inside the code block :D) like different functions, classes etc by using the { and } keys.
  • The best and fastest way to go to move around is by using the available visual cues like keywords on certain lines etc and searching and moving cursor to that point. You can use the / or ? key to search for a particular word and either press Esc to stop search and move to original cursor position or Enter to go to that searched keyword.
  • Of course you can advance by full screens using Ctrl+F and Ctrl+B.
  • You can directly go to a particular line by typing the line number in normal mode and pressing capital G. eg:- 10G

if you're still wanting to explore more navigation tricks and commands, i strongly recommend you to watch this wonderful talk.

like image 22
Yedhin Avatar answered Sep 18 '22 02:09

Yedhin