To save changes in vi (or vim), follow these steps:
- Press
Esc: This ensures you are in command mode. - Type
:wand pressEnter: This command will save the changes you have made to the file.
If you want to save the changes and exit vi at the same time, you can use:
- Type
:wqand pressEnter: This will save the changes and then quit the editor.
If you want to save the changes under a different filename, you can use:
- Type
:w newfilenameand pressEnter: Replacenewfilenamewith the desired name for the file.
Remember to press Esc before typing the colon (:) to enter command mode.
