SlideShare a Scribd company logo
Linux
Text Editor
Vi is a renowned text editor with a rich history in Linux
and Unix environments. It is known for its simplicity and
powerful command-line interface. Indeed, Vi is a go-to tool
for developers and system administrators.
Text Editor
Key Features of Vi Text Editor
 Modal Editing: Unique modes for efficient navigation and content
manipulation.
 Extensive Shortcuts: Accelerate editing tasks with a wide array of
keyboard commands.
 Lightweight and Fast: Minimalistic design ensures quick startup
and responsive performance.
 Command-Line Integration: Seamlessly integrates with the command
line for versatile text editing on the fly.
vi Mode
Command Mode:
o To perform administrative tasks such as saving files, executing commands,
moving the cursor, cutting yanking and pasting lines or words, and finding and
replacing
o To manipulate files (including saving your current file and running outside
programs)
o Command mode by typing a colon (:)
Insert Mode:
o Enter text in insert mode
Starting the vi Editor
Command Description
vi filename Creates a new file if it already does not exist, otherwise opens existing file.
vi -R filename Opens an existing file in read only mode.
view filename Opens an existing file in read only mode.
Moving within a File
Command Description
k Moves the cursor up one line
J Moves the cursor down one line
h Moves the cursor to the left one character position
I Moves the cursor to the right one character position
Common keyboard keys used to change to and from insert mode
Key Description
i Changes to insert mode and places the cursor before the current character for entering text
a Changes to insert mode and places the cursor after the current character for entering text
o Changes to insert mode and opens a new line underneath the current line for entering text
I Changes to insert mode and places the cursor at the beginning of the current line for
entering text
A Changes to insert mode and places the cursor at the end of the current line for entering text
O Changes to insert mode and opens a new line above the current line for entering text
Esc Changes back to command mode while in insert mode
Scrolling Commands
Deleting Characters
Command Description
x Deletes the character under the cursor location.
X Deletes the character before the cursor location.
dw Deletes from the current cursor location to the next word.
d^ Deletes from current cursor position to the beginning of the line.
d$ Deletes from current cursor position to the end of the line.
D Deletes from the cursor position to the end of the current line.
dd Deletes the line the cursor is on.
Commands Description
CTRL+D Moves the screen down by half a page
CTRL+F Scrolls the screen down by a full page
CTRL+U Scrolls the screen up by half a page
CTRL+B Scrolls the screen up by a full page
CTRL+E Scrolls the screen up by one line
CTRL+Y Scrolls the screen down by one line
CTRL+I Redraws the screen
Many other ways to move within a file in vi
Command Description
0 or | Positions cursor at beginning of line
$ Positions cursor at end of line.
w Positions cursor to the next word
b Positions cursor to previous word.
( Positions cursor to beginning of current sentence.
) Positions cursor to beginning of next sentence.
E Move to the end of Blank delimited word
{ Move a paragraph back
} Move a paragraph forward
[[ Move a section back
]] Move a section forward
n| Moves to the column n in the current line
1G Move to the first line of the file
G Move to the last line of the file
nG Move to nth line of the file
:n Move to nth line of the file
fc Move forward to c
Fc Move back to c
H Move to top of screen
nH Moves to nth line from the top of the screen
M Move to middle of screen
L Move to botton of screen
nL Moves to nth line from the bottom of the screen
Change Commands
 To change characters, words, or lines in vi without deleting them
Command Description
cc Removes contents of the line, leaving you in insert mode.
cw Changes the word the cursor is on from the cursor to the lowercase w
end of the word.
r Replaces the character under the cursor. vi returns to command mode
after the replacement is entered.
R Overwrites multiple characters beginning with the character currently
under the cursor. You must use Esc to stop the overwriting.
s Replaces the current character with the character you type. Afterward,
you are left in insert mode.
S Deletes the line the cursor is on and replaces with new text. After the
new text is entered, vi remains in insert mode.
Copy and Past Commands
 Copy lines or words from one place and then you can past them at another
place
Command Description
yy Copies the current line.
yw Copies the current word from the character the lowercase w cursor is
on until the end of the word.
p Puts the copied text after the cursor.
P Puts the yanked text before the cursor.
Searching String Commands
Commands Description
/string Forwards lookup for a given string
?string Backwards lookup for a given string
/^string Forwards search string at the start of a line
/string$ Forwards search string at line’s end
n Proceeds to the next occurrence of the searched string
/<he> Looks for the word he (rather than there, here, and so on)
/pl[abc]ce Looks up the terms place, plbce, and plcce
Saving and Closing File Commands
Command Description
:q! to quit out of vi without saving
:w save the contents of the editor
:wq to save your changes and exit out of vi
ZZ to save your changes and exit out of vi
:w filename2 Can specify a different file name to save

More Related Content

PDF
Using vi editor
PDF
Using VI Editor in Red Hat by Rohit Kumar
PDF
vim-cheatsheet.pdf
PDF
Vi editor Linux Editors
PPT
changing and deleting text ,change word and line under vi editor
PDF
Vi editor commands
PDF
vi cheat sheet
DOC
Qc document draft
Using vi editor
Using VI Editor in Red Hat by Rohit Kumar
vim-cheatsheet.pdf
Vi editor Linux Editors
changing and deleting text ,change word and line under vi editor
Vi editor commands
vi cheat sheet
Qc document draft

Similar to Linux Text Editor (Vi) Command List Summary (20)

PPTX
Vi editor
PPTX
Vi editor
PDF
Vi reference
PDF
Vi reference
PPT
Introduction to vi editor
PPT
VI Editors
PDF
015-Editing-Files-With-Vi.pdf
PPT
intro unix/linux 04
PDF
Vi cheat sheet
PDF
Vi cheat sheet
PPT
07 vi text_editor
PDF
PPTX
Vi Vi Editor Unit 4 Power point presentation
PPTX
Using Vi Editor.pptx
PPTX
Using Vi Editor.pptx
PPT
1359 Vi Editor
PDF
101 3.8.2 vim reference card
PDF
3.8.b vim reference card
PDF
Beginning with vi text editor
PPTX
Vi editor
Vi editor
Vi reference
Vi reference
Introduction to vi editor
VI Editors
015-Editing-Files-With-Vi.pdf
intro unix/linux 04
Vi cheat sheet
Vi cheat sheet
07 vi text_editor
Vi Vi Editor Unit 4 Power point presentation
Using Vi Editor.pptx
Using Vi Editor.pptx
1359 Vi Editor
101 3.8.2 vim reference card
3.8.b vim reference card
Beginning with vi text editor
Ad

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
cuic standard and advanced reporting.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Electronic commerce courselecture one. Pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
KodekX | Application Modernization Development
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Unlocking AI with Model Context Protocol (MCP)
cuic standard and advanced reporting.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Electronic commerce courselecture one. Pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Machine learning based COVID-19 study performance prediction
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
KodekX | Application Modernization Development
Network Security Unit 5.pdf for BCA BBA.
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation theory and applications.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
The AUB Centre for AI in Media Proposal.docx
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Ad

Linux Text Editor (Vi) Command List Summary

  • 2. Vi is a renowned text editor with a rich history in Linux and Unix environments. It is known for its simplicity and powerful command-line interface. Indeed, Vi is a go-to tool for developers and system administrators. Text Editor Key Features of Vi Text Editor  Modal Editing: Unique modes for efficient navigation and content manipulation.  Extensive Shortcuts: Accelerate editing tasks with a wide array of keyboard commands.  Lightweight and Fast: Minimalistic design ensures quick startup and responsive performance.  Command-Line Integration: Seamlessly integrates with the command line for versatile text editing on the fly.
  • 3. vi Mode Command Mode: o To perform administrative tasks such as saving files, executing commands, moving the cursor, cutting yanking and pasting lines or words, and finding and replacing o To manipulate files (including saving your current file and running outside programs) o Command mode by typing a colon (:) Insert Mode: o Enter text in insert mode Starting the vi Editor Command Description vi filename Creates a new file if it already does not exist, otherwise opens existing file. vi -R filename Opens an existing file in read only mode. view filename Opens an existing file in read only mode.
  • 4. Moving within a File Command Description k Moves the cursor up one line J Moves the cursor down one line h Moves the cursor to the left one character position I Moves the cursor to the right one character position Common keyboard keys used to change to and from insert mode Key Description i Changes to insert mode and places the cursor before the current character for entering text a Changes to insert mode and places the cursor after the current character for entering text o Changes to insert mode and opens a new line underneath the current line for entering text I Changes to insert mode and places the cursor at the beginning of the current line for entering text A Changes to insert mode and places the cursor at the end of the current line for entering text O Changes to insert mode and opens a new line above the current line for entering text Esc Changes back to command mode while in insert mode
  • 5. Scrolling Commands Deleting Characters Command Description x Deletes the character under the cursor location. X Deletes the character before the cursor location. dw Deletes from the current cursor location to the next word. d^ Deletes from current cursor position to the beginning of the line. d$ Deletes from current cursor position to the end of the line. D Deletes from the cursor position to the end of the current line. dd Deletes the line the cursor is on. Commands Description CTRL+D Moves the screen down by half a page CTRL+F Scrolls the screen down by a full page CTRL+U Scrolls the screen up by half a page CTRL+B Scrolls the screen up by a full page CTRL+E Scrolls the screen up by one line CTRL+Y Scrolls the screen down by one line CTRL+I Redraws the screen
  • 6. Many other ways to move within a file in vi Command Description 0 or | Positions cursor at beginning of line $ Positions cursor at end of line. w Positions cursor to the next word b Positions cursor to previous word. ( Positions cursor to beginning of current sentence. ) Positions cursor to beginning of next sentence. E Move to the end of Blank delimited word { Move a paragraph back } Move a paragraph forward [[ Move a section back ]] Move a section forward n| Moves to the column n in the current line 1G Move to the first line of the file G Move to the last line of the file nG Move to nth line of the file :n Move to nth line of the file fc Move forward to c Fc Move back to c H Move to top of screen nH Moves to nth line from the top of the screen M Move to middle of screen L Move to botton of screen nL Moves to nth line from the bottom of the screen
  • 7. Change Commands  To change characters, words, or lines in vi without deleting them Command Description cc Removes contents of the line, leaving you in insert mode. cw Changes the word the cursor is on from the cursor to the lowercase w end of the word. r Replaces the character under the cursor. vi returns to command mode after the replacement is entered. R Overwrites multiple characters beginning with the character currently under the cursor. You must use Esc to stop the overwriting. s Replaces the current character with the character you type. Afterward, you are left in insert mode. S Deletes the line the cursor is on and replaces with new text. After the new text is entered, vi remains in insert mode. Copy and Past Commands  Copy lines or words from one place and then you can past them at another place Command Description yy Copies the current line. yw Copies the current word from the character the lowercase w cursor is on until the end of the word. p Puts the copied text after the cursor. P Puts the yanked text before the cursor.
  • 8. Searching String Commands Commands Description /string Forwards lookup for a given string ?string Backwards lookup for a given string /^string Forwards search string at the start of a line /string$ Forwards search string at line’s end n Proceeds to the next occurrence of the searched string /<he> Looks for the word he (rather than there, here, and so on) /pl[abc]ce Looks up the terms place, plbce, and plcce
  • 9. Saving and Closing File Commands Command Description :q! to quit out of vi without saving :w save the contents of the editor :wq to save your changes and exit out of vi ZZ to save your changes and exit out of vi :w filename2 Can specify a different file name to save