SlideShare a Scribd company logo
vi editor basics
a Append text after cursor. h Move cursor left (left arrow; backspace)
A Append text at the end of the line. j Move cursor down (down arrow)
i Insert text before the cursor. k Move cursor up (up arrow)
I Insert text at the beginning of the line. l Move cursor right (right arrow, spacebar)
o Open a new line below the cursor.
O Open a new line above the cursor. H Move to top of screen.
w Move forward one word. M Move to middle of screen.
W Move forward one word past punctuation. L Move to bottom of screen.
b Move backward one word.
B Move backward one word past punctuation. CTRL-f Page forward one screen.
e Move forward at end of word. CTRL-d Scroll down one-half screen.
E Move forward at end of word past punctuation. CTRL-b Page back up one screen.
x Delete character at cursor. CTRL-u Scroll up one-half screen.
X Delete character left of cursor.
:5,10d Delete lines 5 through 10.
D Delete line to right of cursor. :1,3co 5 Copy lines 1 to 3; put after line 5.
dw Delete word right of cursor. :4,6m 8 Move lines 4 to 6 to line 8
ndw Delete n number of words.
dd Delete line containing the cursor. cw Change word.
ndd Delete n lines. ncw Change n words.
dG Delete to end of FILE. nyy Yank n lines (copy).
Y Yank current line.
R Overwrite characters on line. p Put yanked/deleted line(s) below current line.
r Replace one letter only. P Put yanked/deleted line(s) above current ilne.
C Change from cursor to end of line. :r insert_file Insert insert_file below the current line.
s Substitute string for character. :n r
insert_file
Insert insert_file after line number n.
J Join current line and line below current line.
xp Transpose/switch letters. u Undo previous command.
~ Change case of letter. U Undo all changes to current line.
:u Undo previous last line command.
:w Save changes.
:w new_file Save with name new_file :set nu Show line numbers.
:w! existing Overwrite existing file existing :set nonu Hide line numbers,
:wq Save changes and quit vi. :set ic Search ignore case.
ZZ Save changes and quit vi :set noic Search case sensitive
:q! Quit without saving. :set list Display invisible characters (tabs)
:set nolist Don't display invisible characters.
G Go to last line. :set showmode Show current mode of operation.
1G Go to first line of file. :set noshowmode Don't show current mode of operation.
:21 Go to line 21. CTRL-L Clear scrambled screen.
21G Go to line 21.
/string Search forward for string
?string Search backward for string
n Find next occurrence of string
N Find previous occurrence of string
:s/this/that Change first occurrence of this to that on current line.
:s/this/that/g Change all occurrences of this to that on current line.
:%s/this/that On all lines, change first occurrence of this to that.
:%s/this/that/g On all lines, change all occurrences of this to that.
vi Detailed Reference
Search Functions
/exp Go forward to exp
?exp Go backward to exp
Move and Insert Text
:3,8d Delete lines 3-8
:2,4m 9 Move lines 2-4 to 9
:2,4co 9 Copy lines 2-4 to 9
:5,9w file Write lines 5-9 to file
Substitution Functions
:s/old/new Change old to new
:%s/old/new/g Change all old to
new
Save Files and Exit
:w Write buffer to disk
:w newfile Write buffer to newfile
:w! file Write absolutely
:q Quit vi
:q! Quit absolutely
:e! Re-edit, discarding
changes
Control Edit Session
:set nu Display line numbers
:set nonu Don't show line numbers
:set all Show all settings
:set list Display invisible chars
:set showmode Display editing mode
Other Useful Features
:r file Read in file
:!command Execute shell command
:sh Exit to shell
:| Shell cmd results to file
ZZ Write and quit
Screen/Line Movement
j ↓ k ↑ h ← l →
0 Go to line start
$ Go to line end
G Go to last line in file
3G Go to line 3
CTRL-g Show line number
CTRL-f Go forward 1 screen
CTRL-b Go backward 1 screen
Word Movement
W Go forward 1 word
3W Go forward 3 words
B Go back 1 word
3B Go back 3 words
Search Functions
n Repeat previous search
N Reverse previous search
Delete Text
x Delete one character
dw Delete one word
dd Delete one line
D Delete to end of line
d0 Delete to beginning of line
dG Delete to end of file
Cancel/Redo Functions
u Undo last change
. Do last change again
Copy and Insert Text
Y Yank a copy of a line
5Y Yank a copy of 5 lines
p Put below cursor
P Put above cursor
Word Processing Functions
J Join next line to current
4J Join next 4 lines to current
Add/Append Text
a Append after cursor
A Append at line end
i Insert before cursor
5i Insert text 5 times
I Insert at beginning of line
Add New Lines
o Open a line below cursor
O Open a line above cursor
Change Text
cw Change a word
3cw Change 3 words
C Change line
r Replace one character
R Replace/type-over line
Last Line
Mode
Command
Mode Input
Mode
:/?
Enter
Esc
Input cmds

More Related Content

Similar to Vi reference

Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
Farrukh Salman
 
Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
Kopi Maheswaran
 
015-Editing-Files-With-Vi.pdf
015-Editing-Files-With-Vi.pdf015-Editing-Files-With-Vi.pdf
015-Editing-Files-With-Vi.pdf
ssuser584832
 
Using VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit KumarUsing VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit KumarRohit Kumar
 
vim-cheatsheet.pdf
vim-cheatsheet.pdfvim-cheatsheet.pdf
vim-cheatsheet.pdf
AnkitPangasa1
 
Vi editor
Vi editorVi editor
Vi editor
Ramakrishna kapa
 
Vim Cheat Sheet.pdf
Vim Cheat Sheet.pdfVim Cheat Sheet.pdf
Vim Cheat Sheet.pdf
AdelinaBronda1
 
Vi editor commands
Vi editor commandsVi editor commands
Vi editor commands
Femi Adeyemi
 
Vi Editor Cheat Sheet
Vi Editor Cheat SheetVi Editor Cheat Sheet
Vi Editor Cheat Sheet
Loiane Groner
 
VI Editors
VI EditorsVI Editors
VI EditorsDeivanai
 
Rubizza #1 | Special Lecture. Vim
Rubizza #1 | Special Lecture. Vim Rubizza #1 | Special Lecture. Vim
Rubizza #1 | Special Lecture. Vim
Rubizza
 
API TEST
API TESTAPI TEST
API TEST
copremesis
 
API TEST
API TESTAPI TEST
API TEST
copremesis
 
Vi Cheat Sheet
Vi Cheat SheetVi Cheat Sheet
Vi Cheat Sheet
Loiane Groner
 
Beginning with vi text editor
Beginning with vi text editorBeginning with vi text editor
Beginning with vi text editor
Jose Pla
 
Vim Cards - Powerpoint Format
Vim Cards - Powerpoint FormatVim Cards - Powerpoint Format
Vim Cards - Powerpoint Format
Adam Lowe
 
changing and deleting text ,change word and line under vi editor
changing and deleting text ,change word and line under vi editorchanging and deleting text ,change word and line under vi editor
changing and deleting text ,change word and line under vi editor
Shourya Puri
 

Similar to Vi reference (20)

Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
 
Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
 
015-Editing-Files-With-Vi.pdf
015-Editing-Files-With-Vi.pdf015-Editing-Files-With-Vi.pdf
015-Editing-Files-With-Vi.pdf
 
Using VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit KumarUsing VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit Kumar
 
Using vi editor
Using vi editorUsing vi editor
Using vi editor
 
vim-cheatsheet.pdf
vim-cheatsheet.pdfvim-cheatsheet.pdf
vim-cheatsheet.pdf
 
Vi editor
Vi editorVi editor
Vi editor
 
Vim Cheat Sheet.pdf
Vim Cheat Sheet.pdfVim Cheat Sheet.pdf
Vim Cheat Sheet.pdf
 
Vi editor commands
Vi editor commandsVi editor commands
Vi editor commands
 
Vim
VimVim
Vim
 
Vi Editor Cheat Sheet
Vi Editor Cheat SheetVi Editor Cheat Sheet
Vi Editor Cheat Sheet
 
VI Editors
VI EditorsVI Editors
VI Editors
 
Rubizza #1 | Special Lecture. Vim
Rubizza #1 | Special Lecture. Vim Rubizza #1 | Special Lecture. Vim
Rubizza #1 | Special Lecture. Vim
 
Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
 
API TEST
API TESTAPI TEST
API TEST
 
API TEST
API TESTAPI TEST
API TEST
 
Vi Cheat Sheet
Vi Cheat SheetVi Cheat Sheet
Vi Cheat Sheet
 
Beginning with vi text editor
Beginning with vi text editorBeginning with vi text editor
Beginning with vi text editor
 
Vim Cards - Powerpoint Format
Vim Cards - Powerpoint FormatVim Cards - Powerpoint Format
Vim Cards - Powerpoint Format
 
changing and deleting text ,change word and line under vi editor
changing and deleting text ,change word and line under vi editorchanging and deleting text ,change word and line under vi editor
changing and deleting text ,change word and line under vi editor
 

Recently uploaded

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 

Recently uploaded (20)

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 

Vi reference

  • 1. vi editor basics a Append text after cursor. h Move cursor left (left arrow; backspace) A Append text at the end of the line. j Move cursor down (down arrow) i Insert text before the cursor. k Move cursor up (up arrow) I Insert text at the beginning of the line. l Move cursor right (right arrow, spacebar) o Open a new line below the cursor. O Open a new line above the cursor. H Move to top of screen. w Move forward one word. M Move to middle of screen. W Move forward one word past punctuation. L Move to bottom of screen. b Move backward one word. B Move backward one word past punctuation. CTRL-f Page forward one screen. e Move forward at end of word. CTRL-d Scroll down one-half screen. E Move forward at end of word past punctuation. CTRL-b Page back up one screen. x Delete character at cursor. CTRL-u Scroll up one-half screen. X Delete character left of cursor. :5,10d Delete lines 5 through 10. D Delete line to right of cursor. :1,3co 5 Copy lines 1 to 3; put after line 5. dw Delete word right of cursor. :4,6m 8 Move lines 4 to 6 to line 8 ndw Delete n number of words. dd Delete line containing the cursor. cw Change word. ndd Delete n lines. ncw Change n words. dG Delete to end of FILE. nyy Yank n lines (copy). Y Yank current line. R Overwrite characters on line. p Put yanked/deleted line(s) below current line. r Replace one letter only. P Put yanked/deleted line(s) above current ilne. C Change from cursor to end of line. :r insert_file Insert insert_file below the current line. s Substitute string for character. :n r insert_file Insert insert_file after line number n. J Join current line and line below current line. xp Transpose/switch letters. u Undo previous command. ~ Change case of letter. U Undo all changes to current line. :u Undo previous last line command. :w Save changes. :w new_file Save with name new_file :set nu Show line numbers. :w! existing Overwrite existing file existing :set nonu Hide line numbers, :wq Save changes and quit vi. :set ic Search ignore case. ZZ Save changes and quit vi :set noic Search case sensitive :q! Quit without saving. :set list Display invisible characters (tabs) :set nolist Don't display invisible characters. G Go to last line. :set showmode Show current mode of operation. 1G Go to first line of file. :set noshowmode Don't show current mode of operation. :21 Go to line 21. CTRL-L Clear scrambled screen. 21G Go to line 21. /string Search forward for string ?string Search backward for string n Find next occurrence of string N Find previous occurrence of string :s/this/that Change first occurrence of this to that on current line. :s/this/that/g Change all occurrences of this to that on current line. :%s/this/that On all lines, change first occurrence of this to that. :%s/this/that/g On all lines, change all occurrences of this to that.
  • 2. vi Detailed Reference Search Functions /exp Go forward to exp ?exp Go backward to exp Move and Insert Text :3,8d Delete lines 3-8 :2,4m 9 Move lines 2-4 to 9 :2,4co 9 Copy lines 2-4 to 9 :5,9w file Write lines 5-9 to file Substitution Functions :s/old/new Change old to new :%s/old/new/g Change all old to new Save Files and Exit :w Write buffer to disk :w newfile Write buffer to newfile :w! file Write absolutely :q Quit vi :q! Quit absolutely :e! Re-edit, discarding changes Control Edit Session :set nu Display line numbers :set nonu Don't show line numbers :set all Show all settings :set list Display invisible chars :set showmode Display editing mode Other Useful Features :r file Read in file :!command Execute shell command :sh Exit to shell :| Shell cmd results to file ZZ Write and quit Screen/Line Movement j ↓ k ↑ h ← l → 0 Go to line start $ Go to line end G Go to last line in file 3G Go to line 3 CTRL-g Show line number CTRL-f Go forward 1 screen CTRL-b Go backward 1 screen Word Movement W Go forward 1 word 3W Go forward 3 words B Go back 1 word 3B Go back 3 words Search Functions n Repeat previous search N Reverse previous search Delete Text x Delete one character dw Delete one word dd Delete one line D Delete to end of line d0 Delete to beginning of line dG Delete to end of file Cancel/Redo Functions u Undo last change . Do last change again Copy and Insert Text Y Yank a copy of a line 5Y Yank a copy of 5 lines p Put below cursor P Put above cursor Word Processing Functions J Join next line to current 4J Join next 4 lines to current Add/Append Text a Append after cursor A Append at line end i Insert before cursor 5i Insert text 5 times I Insert at beginning of line Add New Lines o Open a line below cursor O Open a line above cursor Change Text cw Change a word 3cw Change 3 words C Change line r Replace one character R Replace/type-over line Last Line Mode Command Mode Input Mode :/? Enter Esc Input cmds