Vi Editor.
The vi editor is a powerful text editor commonly found in Unix and Unix-like
operating systems. It operates in different modes and has a variety of commands
for editing text. Here’s a brief overview of its features and basic commands to help
you get started:
Basic Modes in vi
1. Normal Mode: This is the default mode. You can navigate and issue
commands but not insert text.
2. Insert Mode: You can insert text. You enter this mode by pressing i, I, a, A,
o, or O.
3. Command-Line Mode: You can execute commands, such as saving or
exiting. You enter this mode by pressing: from normal mode.
Basic Commands
vi filename (press enter)
Switching Modes:
Enter Insert Mode:
o i (insert before the cursor)
o a (insert after the cursor)
Before
After
o o (open a new line below)
Navigation (in Normal Mode):
h : move left
j : move down
k : move up
l : move right
gg : go to the top of the file
G : go to the bottom of the file
:n : go to line number n
Editing Text:
x : delete the character under the cursor
dd : delete the current line
yy : copy (yank) the current line
p : paste the copied line after the current line
Saving and Exiting:
:w : save the file
:q : quit
:wq : save and quit
:q! : quit without saving