0% found this document useful (0 votes)
56 views2 pages

VI Tutorial

The document provides an introduction to the vi text editor, outlining its basic modes of command mode and insert mode, and giving examples of common vi commands for opening and saving files, moving the cursor, entering and exiting insert mode, undoing and deleting text, repeating commands, searching and replacing text, and more. It also introduces visual mode for selecting blocks of text and copying and pasting. The document serves as a tutorial for getting started with basic vi commands and navigation.

Uploaded by

wisdomonah18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views2 pages

VI Tutorial

The document provides an introduction to the vi text editor, outlining its basic modes of command mode and insert mode, and giving examples of common vi commands for opening and saving files, moving the cursor, entering and exiting insert mode, undoing and deleting text, repeating commands, searching and replacing text, and more. It also introduces visual mode for selecting blocks of text and copying and pasting. The document serves as a tutorial for getting started with basic vi commands and navigation.

Uploaded by

wisdomonah18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

vi Tutorial

Ben Pharr <[email protected]>

• Why spend time learning a text editor?


• Why vi?
• vim – vi improved
• vi has two basic modes, command mode and insert mode

The Bare Minimum


vi vitest Open a new or existing file (starts in command mode)
i Enter insert mode
Your Name Type your name
[Enter] Press the enter key to start a new line
Your favorite food Type the name of your favorite food
[Enter] Press the enter key to start a new line

[Esc] Press the escape key to enter command mode


:w [Enter] Save (write) the file

i Enter insert mode


Use the arrow keys to place the cursor below favorite food
Your favorite element Type the name of your favorite chemical element
[Enter] Press the enter key to start a new line
The quick brown fox jumps over the lazy dog.
[Enter] Press the enter key to start a new line

[Esc] Press the escape key to enter command mode


:w [Enter] Save (write) the file
:q [Enter] Exit (quit) vi
OR
:x [Enter] Save and exit vi

less vitest Have a look at your file in less

Moving Around in Command Mode


w Move one word to the right
gg Move to the beginning of the file
G Move to the end of the line
^ Move to the beginning of the line
$ Move to the end of the line
:line_number [Enter] Move to a specific line

Different ways of entering insert mode


a Insert after cursor
I Insert at the beginning of the line
A Insert at the end of line
Undo
:u [Enter]
[Esc]:q!

Deleting Text
x Delete the character under the cursor
dd Delete the current line
d$ Delete to the end of the line

Repeating Commands
. Repeat last command
nc Repeat command c n times
3dd Delete three lines
4w Move four words to the right

Changing text
~ Change the case of the current character
r Change the current character
R Overwrite

Copy and Paste


yy Copy (yank) the current line
y$ Yank to the end of the line
p Paste the last thing that was copied

Visual Mode
v Enter visual mode
Use arrow keys to select text
y Copy selected text
p Paste text

V Enter visual line mode

Search
/text Search for text
:%s/text/newtext/ Search for text and replace with newtext

Other
:e file Edit another file
.vimrc

You might also like