Editing Text
1. Inserting Text:
In Insert Mode, type your text as needed.
# In Insert Mode, type your text.
This is some text you can edit. [You are in Insert Mode]
2. Deleting Text:
In Normal Mode, use x to delete the character under the cursor, dd to delete the entire line, or D to delete from the cursor position to the end of the line.
# In Normal Mode, 'x' deletes the character under the cursor.
This is some t xt you can edit. [Cursor on 'e']
# 'dd' deletes the entire line.
This line will be deleted.
# 'D' deletes from the cursor position to the end of the line.
This line is deleted. [Cursor on 'i']
3. Copying and Pasting:
To copy text, use yy. To paste, press p to paste below the cursor or P to paste above the cursor.
# In Normal Mode, 'yy' copies the current line.
This is a line to copy.
# 'p' pastes the copied line below the cursor.
This is a line to copy.
This is the pasted line.
# 'P' pastes the copied line above the cursor.
This is the pasted line.
This is a line to copy.
Basic vi Commands
Text editors are essential tools for any programmer or computer enthusiast. One popular text editor that has been around for decades and is still widely used is vi (pronounced “vee-eye”). vi is a terminal-based text editor that offers powerful editing capabilities once you understand its basic commands.
In this article, we will explore the fundamental vi commands that will help you navigate, edit, and save your text files efficiently. Whether you’re a beginner or an experienced user looking to refresh your knowledge, this guide will provide you with a solid foundation in using vi.