0% found this document useful (0 votes)
34 views3 pages

Vi Editor Cheat Sheet

This document is a cheat sheet for the Vi editor, providing essential commands for starting, quitting, and switching modes. It includes instructions for moving around, editing text, searching and replacing, and other useful commands. The cheat sheet serves as a quick reference for users to efficiently navigate and utilize the Vi editor.

Uploaded by

haruoyoshida0731
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)
34 views3 pages

Vi Editor Cheat Sheet

This document is a cheat sheet for the Vi editor, providing essential commands for starting, quitting, and switching modes. It includes instructions for moving around, editing text, searching and replacing, and other useful commands. The cheat sheet serves as a quick reference for users to efficiently navigate and utilize the Vi editor.

Uploaded by

haruoyoshida0731
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/ 3

Vi Editor Cheat Sheet

Starting and Quitting Vi

vi filename - Open a file named 'filename'

:w - Save (write) file

:q - Quit Vi

:wq - Save and quit

:q! - Quit without saving

:w filename - Save file under a new name

Switching Modes

i - Insert before cursor

I - Insert at beginning of line

a - Append after cursor

A - Append at end of line

o - Open a new line below cursor

O - Open a new line above cursor

Esc - Return to Normal mode

Moving Around

h - Move left

l - Move right

j - Move down

k - Move up

0 - Move to beginning of line

$ - Move to end of line

w - Jump forward to start of next word

b - Jump backward to start of previous word


Vi Editor Cheat Sheet

G - Go to end of file

gg - Go to beginning of file

:n - Go to line number n

Editing Text

x - Delete character under cursor

dd - Delete entire current line

dw - Delete from cursor to end of word

D - Delete from cursor to end of line

yy - Copy (yank) current line

yw - Yank current word

p - Paste after cursor

P - Paste before cursor

u - Undo last action

Ctrl + r - Redo undone action

Searching and Replacing

/pattern - Search for pattern forward

?pattern - Search for pattern backward

n - Repeat last search forward

N - Repeat last search backward

:%s/old/new/g - Replace all 'old' with 'new' in file

:n,m s/old/new/g- Replace 'old' with 'new' between lines n and m

Other Useful Commands

:set number - Show line numbers


Vi Editor Cheat Sheet

:set nonumber - Hide line numbers

:syntax on - Enable syntax highlighting

:syntax off - Disable syntax highlighting

:help - Open help documentation

You might also like