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

VI Editor Cheat Sheet

The document provides a cheat sheet for using the vi text editor. It lists commands for opening and saving files, inserting and deleting text, searching and replacing text, moving the cursor, and more. The cheat sheet contains over 50 vi commands organized into sections.

Uploaded by

Zoumana Diomande
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)
84 views2 pages

VI Editor Cheat Sheet

The document provides a cheat sheet for using the vi text editor. It lists commands for opening and saving files, inserting and deleting text, searching and replacing text, moving the cursor, and more. The cheat sheet contains over 50 vi commands organized into sections.

Uploaded by

Zoumana Diomande
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 editor Cheat Sheet

File Open Saving and Quitting Moving Cursor in file


Open or create Save changes (write h Move one character left
vi filename file :w buffer)
j Move one line down
Open new file to Write buffer to
k Move one line up
vi be named later :w filename named file
Move one
Recover crashed Save changes and
l character to right
vi -r filename file :wq quit vi
w Move one word right
Open file read- Save changes and
view filename only ZZ quit vi Move one word (past
W punctuation) right
Insert Characters and Lines Quit without saving
:q! changes b Move one word left
Insert
characters right of Move one word (past
a cursor Text Change Operations B punctuation) left
Insert characters end cc Change line Move to of current
A of line Change characters e word end
Insert characters left in a word or entire
i of cursor cw word right of cursor
Moving Cursor with keys
Insert Change from
Return/Enter Move down one
characters beginning cursor cursor to
key line down
I of line C end of line
Move left one
Insert line below Substitute string for
Backspace character left
o cursor character(s) from
s cursor forward Move right one
Insert line above Spacebar character right
O cursor Replace character
with other Moving on Screen
Delete Text in file r character at cursor
H Move to of screen top
Delete character at r Return Break line at cursor
x the cursor Move to middle of
Join to current M screen
Delete character to J line line below
the left of the Move to bottom of
X cursor Transpose L screen
character cursor
Delete word (or part and character to Moving on Screen using ctrl
of word to right of xp right key combination
dw cursor) Page forward one
Change case of
Delete current letter to uppercase Ctrl-f screen forward
dd line or lowercase at Scroll forward one-
Delete part of line ~ cursor Ctrl-d half screen
D to right of cursor Undo previous Page backward one
Delete to end of u command Ctrl-b screen
dG file Undo all changes to Scroll backward
Delete - beginning U current line Ctrl-u one-half screen
d1G of file to cursor Undo previous
:1,4 d Delete lines 1 to 4 :u line command
Copy and Move lines Inserting a File Into a File set/ignore case for search
Yank or Insert (read) file Searches should
yy copy current line :r filename after cursor :set ic ignore case
4yy Copy 4 lines Insert file after Searches should be
:34 r filename line 34 :set noic case sensitive
Y Yank or copy line
Show/hide Line Numbers Clearing the Screen
Put yanked or
deleted line below :set Show line Clear screen of std-
p current line nu numbers for all lines Ctrl-L io messages
Put yanked or :set
Executing Shell Command
deleted line above nonu Hide numbers for all line
P current line Execute command -
go to line
Copy lines 1-2
:!cmd cmd
G Go to last line of file
:1,2 co 3 and put after line 3
1G Go to first line of file
Move lines 4-6 and
:4,6 m 7 put after line 7 21G Go to line 21

Search and Replace

/string Search for string anywhere in file


?string Search backward for string

n Find next occurrence of string in search direction

N Find previous occurrence of string in search direction


:%s/search/s/replace/g Search and replace in file

Visit for more Linux and Unix Articles and References at:

AdminsChoice.com
http://adminschoice.com

You might also like