# Quick Reference Study Notes for Vi Editor (Advanced) << Back to Exam

VI EDITOR

Introduction:

Vi is the open source Screen Oriented Text editor which was originally created for UniX like operating systems. Vi editor initially released in 1976 and written in c programing language. Vi is stands for visual editor.

Syntax:

vi <filename>

Vi editor is very easy to use and easy to do manipulations with file’s contents. Right now I’ll let you know how you can create the file with the help of vi editor. As per above syntax you can create the file, like I want to create the file with name example.txt for this I just need to follow the following command into the command terminal.

:~$vi example.txt Vi editor Modes: I hope the file with name example.txt has been created. Before I start further concept, you would need to understand the key components of vi editor. Vi editor comes with three different modes with differents functionalities. I have mentioned the three vi editor modes as below: 1. Input Mode 2. Vi Mode/Row Editing Mode 3. Commands mode Input Mode Input mode is used to insert the text into the created blank file, When you create a vi file then you would have to change the vi mode to input mode. After that you can able to write on the vi file. I have mentioned the commands of input mode as below charts. Please look at them for the more understanding. I have also attached the screenshot that showing how I wrote the texts with the help of input mode. Vi Mode/Row Editing Mode Rest of manipulations are performed under VI mode like copy the lines(lower n numbers of lines or upper n numbers of lines from current cursor location), paste the lines, remove any specific word or line and many more. These all operations are performed under vi mode. You can change the input mode to vi mode with the help of <esc> button. Command Mode Command mode is used to performed the operations like save and quit, quit without save and search any specific word in the vi file, In this mode all commands are followed by colon ”:” and forward slash ”/”, you can look at the chart for understand as I mentioned below. Commands and Description on vi editor : Some important vi editor commands and their description is provided below: – Input mode:  Command Description i Insert at the cursor location. a Insert after the cursor location. I Insert at the start of the cursor line. A Insert at the end of the cursor line. o Insert with new line, after cursor line. O Insert with new line, before cursor line. Vi Mode/Row Editing Mode:  Command Description yy Copy the cursor line. 5yy Copy the five line after the cursor line. 5y Copy the five line before the cursor line. yw Copy the cursor work. yc Copy cursor character. y$ Copy cursor to end of line. p Paste the copied data after cursor line. P Paste the copied data before cursor line. y^ Copy cursor to start of line y( Copy cursor to start of the paragraph. y) Copy cursor to end of the paragraph. dw Remove the word dd Remove the line n Repeat last search in forward order N Repeat last search in reverse order gg Goto top of the file. G got to bottom of the file. 10gg Goto line number 10.

Commands mode

 Command Description :q Quit :wq write and quit :w write :x Save and quit :q! Quit without save :num Goto line number /text Search the specific word in forward order ?text Search the specific word in reverse order

*NOTE : "This study material is collected from multiple sources to make a quick refresh course available to students."