VI Editor - Linux Tutorial #14

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to the video tutorial on vi editor there are many ways to edit files on a Linux operating system we can either use the GUI or work on the terminal for those who like to go with the terminal the VI editor is the most popular and classic text editor in the Linux family some reasons which make it a widely used editor are first it is available in almost all the Linux distributions it works the same across different platforms and distributions it is user friendly hence millions of 0x users love it and use it for the editing needs nowadays they advanced versions of the VI editor available and the most popular one among them is vent which is VI improved some of the other ones are Alvis and VI Nano and file it is wise to learn VI because it is feature-rich and it offers endless possibilities to edit a file in order to work on VI editor you need to understand its operation modes they can be divided into two main parts and the first part is the command mode the VI editor opens in this mode and it only understands commands in this mode you can move the cursor and cut copy paste the text this mode also saves the changes you have made to the file commands are case sensitive so make sure you use the right letter and case the second part is the insert mode this mode is for inserting text in the file you can switch to the insert mode from the command mode by pressing I on the keyboard once you are in the insert mode any key would be taken as an input for the file on which you are currently working to return to the command mode and save the changes you have made you need to press the Escape key so moving on to starting the VI editor you need to open the terminal and type VI is pasted a new file name or VI space an existing file name you can create a new file or edit an existing one this is how we will create a new file in VI editor and it would open in the command mold on the launch screen we see a lot of team decides on the left they denote unused lines for this the file length that you have created shows at the bottom now in order to add content to this file you need to press the i key on the keyboard and only then you would be able to type in something now let's learn some of the VI editing command which should be noted here that you need to be in the command mode to execute these commands also VI lter is case sensitive so make sure you type the commands in the write letter case so let us go ahead and try some of the VI editing commands on terminal as mentioned earlier when you enter the VI mode it is on the command mode by default in order to add content you need to press the i key on the keyboard and only then you would be able to write something otherwise if I go ahead and type in hi right now I would get the error buzz on the system VI editor does not display any change on the screen when you jump from the command mode to the insert mode or vice versa this is an important point to keep in mind while you are editing or creating files on the VI editor so let's press I and add some content once you are done writing the content and you want to save the file you cannot do so in the insert mode you need to jump back to the command mode to do so and in order to move from the insert mode to the command mode you need to press the Escape key on the keyboard once you have done it you will no longer be able to write or edit the file so let's say I want to open a new lion when I am in the command mode I need to press the old letter on the keyboard and the VI editor would open a new line for me and then side mode I can go ahead and type in more content and here if I want to undo all the changes to the entire line I need to go back to the command mode by pressing the Escape key and then press the letter U in the upper case this way all the changes made to the entire line would be reverted now let's say if I want to write off the cursor I can press the letter A in the small case when I'm in the command mode once I do it I can go ahead and write the content again make sure that you press the right command otherwise you will end up making undesirable changes to the file these are some more of the commands that you can use in the cub and mold let us now learn how to move within a file you need to be in the command mode in order to navigate in a file the default keys for navigation are K G H and L or you can also use the arrow keys on the keyboard let us try some of them right now I'm in the command mode now I can always use the arrow keys to navigate within a file otherwise you can use the L key on the keyboard to move right the H key to move left the K key to move up and the key J to move down this is how you can navigate in a file that you are editing when it comes to saving and closing the file you should be again in the command with mode the keystrokes are so if you want to save the file and quit you can either use the shift + Z to set the key combination or you can use the : W Q if you want to save the file but keep it open then you can use the : W or if you want to quit without saving : q is the key combination so let us go ahead and save this file that we have created in order to do so we will press the Escape key to enter the command mode once done we will then press the shift + Z Z key combination and we would return to the terminal the other method to save and exit the file is by typing in : WQ when you are in the command mode we'll see of time - 10 press ENTER and he would return to the command prompt now in order to view the file that we created we need to type in cat space file name and here is the file that we made this is how you can use the VI editor to create a new file or edit existing one let us quickly recap what we learned in this tutorial the VI editor is the most popular and commonly used Linux text editor it is usually available in all Linux distributions it works in two modes command and insert command mode takes the user commands and the insert mode is for editing text you should know the commands in order to work on your file easily learning to use this editor can benefit you in creating scripts and editing files thank you for watching this tutorial I'll see you in the next one
Info
Channel: Guru99
Views: 266,888
Rating: 4.8288136 out of 5
Keywords: vi command, unix tutorial, vi modes, search and replace in vi editor, edit file in linux, best tutorial for vi editor, linux/vi, how to use vi editor in unix, how to use vi editor in ubuntu, how to use vi editor in ubuntu terminal, how to use vi editor, how to use vi editor in linux, find a word and replace in vi editor, vi editor, vi linux, vi editor in linux tutorial, guru99 linux youtube, linux tutorial for beginners guru99
Id: pU2k776i2Zw
Channel Id: undefined
Length: 7min 39sec (459 seconds)
Published: Fri Feb 22 2013
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.