You can get the advice from IT HELP DESK
This time I will try to learn about the VI editor ~
This is one of the most embarrassing things that many people have encountered with Linux OS!
" How do I edit a file or document? "
But did you know that it is so convenient to know?
So this time, I want to learn how to use the VI editor, a text editor for Linux.
1. What is a VI Editor?
The vi editor is an abbreviation for the VIsual display editor. It is a text editor used by Linux and Unix.
It's easy to say that Windows provides features like Notepad.
But if you actually use the vi editor, you'll soon know it's not just a notepad.
With the vi editor, you can develop programs without a separate development tool, and you can edit documents quickly and easily using the many shortcuts that the vi editor supports.
So first, let's run the vi editor before we learn more about the vi editor.
To run the vi editor, type " vi <CR> " at the Linux prompt.
Where <CR> is the symbol for entering Enter! Please refer to ~
If you type in vi and hit Enter, the vi editor will run as shown below.
[Figure 1 - VI editor execution screen]
The vi editor has two main modes.
I also tried the vi editor, and I briefly see what mode it is.
Now let's see how you can actually modify the text with some commands.
2. Edit VI Editor Document Command
1) Start VI
|vi file||Open file|
|vi file1 file2||Open file1 and file2 in order|
2) Quit VI
|:w||Save to specified file|
|:wq||Save and quit vi|
|:x||same as wq|
|ZZ||same as wq|
|:q!||Force quit vi without saving|
3) Move cursor command
|^ or 0||Move to the top of the line|
|$||Move to the end of the line|
|H||Move to the top line of the current viewing screen|
|M||Move to the middle line of the current viewing screen|
|L||Move to the bottom line of the current viewing screen|
|gg||Move to the top line of the file|
|G||Go to the bottom line of the file|
|:n||Move to nth line|
4) Edit mode command
|i||Enter a character before the cursor|
|I||Type character after the cursor|
|a||Type character after the cursor|
|A||Enter characters from the end of the line where the cursor is located|
|O||Insert a blank line below the line with the cursor|
|O||Insert a blank line above the line with the cursor|
5) Edit string command
|x||Clear text behind the cursor|
|X||Clear text before the cursor|
|dd||Clear current cursor line|
|D||Clear all data after one line of the cursor|
|yy||Copy one line where the cursor is located|
|3yy||Copy 3 lines based on where the cursor is located|
|p||Insert the copied content behind the cursor|
|P||Insert the copied content before the cursor|
6) Find a string
|/Words you want to find||Search for the word you want to find|
|n||Go to the next searched word|
|N||Go to the previous word found in the searched words|
I've read the vi editor so far. It's difficult at first, but if you continue to write it, you'll think it's as easy as this! I will continue to work hard ~ !!!
Enter all the pictures!
#LINUX #VI #vieditor