How Do You Delete 4 Lines Using the Vi Unix Editor?
Contents

How do I delete 4 lines from the current cursor position in vi?

Press the Esc key to make sure your are not in an edit mode. Place the cursor on the first line to be deleted. Enter :5dd . The current line, and the next four lines should be deleted.

How do you select and delete in vi?

Type Shift-v to enter linewise selection mode, then move the cursor down using j (yes, use h , j , k and l to move left, down, up, right respectively, that’s much more efficient than using the arrows) and type d to delete the selection.

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest