nerdexam
CompTIA

LX0-103 · Question #129

Immediately after deleting 3 lines of text in vi and moving the cursor to a different line, which single character command will insert the deleted content below the current line?

The correct answer is C. p (lowercase). In vi, the lowercase 'p' command pastes yanked or deleted text after the current cursor position - below the current line for linewise deletions.

GNU and Unix Commands

Question

Immediately after deleting 3 lines of text in vi and moving the cursor to a different line, which single character command will insert the deleted content below the current line?

Options

  • Ai (lowercase)
  • BP (uppercase)
  • Cp (lowercase)
  • DU (uppercase)
  • Eu (lowercase)

How the community answered

(24 responses)
  • B
    8% (2)
  • C
    88% (21)
  • E
    4% (1)

Why each option

In vi, the lowercase 'p' command pastes yanked or deleted text after the current cursor position - below the current line for linewise deletions.

Ai (lowercase)

The 'i' command enters insert mode for typing new text and does not paste previously deleted content.

BP (uppercase)

Uppercase 'P' pastes the deleted content before (above) the current line, not below it.

Cp (lowercase)Correct

In vi, 'p' (lowercase) places the most recently deleted or yanked text after the current cursor position, and because deleting 3 lines is a linewise operation, the content is inserted below the current line. This is distinct from 'P' (uppercase), which inserts before the current line. The deleted content remains in vi's unnamed register until overwritten, so moving the cursor does not clear it.

DU (uppercase)

Uppercase 'U' restores the current line to its original state before any edits were made on that line and does not paste deleted content.

Eu (lowercase)

Lowercase 'u' undoes the last change, which would undo the deletion rather than paste the deleted content at a new location.

Concept tested: vi paste command after linewise deletion

Source: https://vimdoc.sourceforge.net/htmldoc/change.html#p

Topics

#vi editor#paste command#yank and put#text editing

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice