vi/vim navigation — scroll half a page backward (up) In vi/vim normal mode, which control-key command scrolls the screen up by half a page (i.e., a half-page backward)?

Difficulty: Easy

Correct Answer: [Control - u]

Explanation:


Introduction / Context:
Beyond single-line cursor moves, vi/vim provides efficient paging commands to move through large files quickly. Knowing half-page and full-page scrolls is essential for rapid navigation without losing context.



Given Data / Assumptions:

  • Editor is vi/vim in normal mode.
  • We need the half-page scroll upward (backward through the file).
  • Default key bindings are in effect.


Concept / Approach:

In vi/vim, Ctrl+U scrolls upward by half a screen (half a page). Its opposite is Ctrl+D, which scrolls downward by half a screen. Full-page equivalents are Ctrl+B (back) and Ctrl+F (forward). These scrolling commands move the window while keeping the cursor in view.



Step-by-Step Solution:

Ensure normal mode (press Esc).Press Ctrl+U to scroll up by half a page.Use Ctrl+D to scroll down by half a page if needed.For full pages, use Ctrl+B (up) and Ctrl+F (down).


Verification / Alternative check:

Open a long file, note the line numbers on the screen, press Ctrl+U, and observe that the topmost line advances toward lower numbers by roughly half the window height. Repeat with Ctrl+D to confirm symmetry.



Why Other Options Are Wrong:

  • [Control-d]: scrolls half a page down (forward), not up.
  • [Control-c]: interrupts operations in many shells/contexts, not a vi scroll.
  • [Control -P]: not a standard vi paging command; in insert mode Ctrl+P may complete words in vim but does not scroll.
  • None of the above: incorrect because Ctrl+U is correct.


Common Pitfalls:

Confusing Ctrl+U with undo (u); mixing up half-page commands (Ctrl+U vs Ctrl+D); forgetting that these are view scrolls and do not change file content.


Final Answer:

[Control - u]

More Questions from Unix

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion