Oeasy teaches you to play VIM – 6 – # save changes

Time:2022-5-23

Save and save
Recall the last lesson

force quit

We entered insert mode last time
From the normal mode, press < KBD > I < / KBD > to enter the insertion mode
From insert mode, press < KBD > Ctrl < / KBD > + < KBD > C < / KBD > to return to normal mode
This time, let's think about how to save this file

ls -l . > oeasy.txt
vi oeasy.txt

Save file

First, query the help related to save
:h save
Just found SaveAs {file}
At first glance, it is saved as

force quit

Let's try < KBD > I < / KBD > to enter insertion mode
Typing casually
Then save as: SaveAs o2z txt
This o2z Txt is the parameter of SaveAs, that is, the saved file name
Then exit: Q

cat o2z.txt

You can see the saved o2z Txt is really saved!, But can I save the current file directly?
Direct storage

We open oeasy again txt
Let's continue to check the help: H save
Turn up force quit

Write command

Found a: w [rite] Command
    Complex writing is: write
    The simple expression is: W
We'll modify the file again
Note the file name oeasy The [+] in txt [+] is the flag that has been modified but not saved
Then: W

write
Status bar in the lower left corner

We look at the status bar in the lower right corner, which shows:

file name
Number of rows
Number of characters
If not, just: file

Then we’ll quit

Let's first perform the operation: Q then perform cat to view oeasy txt
It has really been modified!!!

summary

This time we learned the save as command: SaveAs {file}
There is also a direct Save command: W
You can really save the modified content
What else to play?
We'll talk about it next time!