Create, Save and Exit in Vim Editor |
Vi used to edit all kinds of plain text. It is especially useful for editing a file/programs.
To Create a New File
vi
colon ( : ) is command line mode, edit command and /tmp/linuxtopic file name with full path
OR
vi /tmp/linuxtopic
It will create a file in /tmp directory with filename linuxtopic if file will already exist with same name will be open.
To edit file
Go to the Insert mode by pressing ( i ) or ( Insert ) key and start typing
To Save Changes in File
Go to command line mode by pressing esc key and type :w
:w
4 lines and 22 character written in the file
To Exit vi editor
We can use :q to exit vi editor
:q
To save and exit together
:wq
We can use ! for forcefully action
:w!
:q!
:wq!
To view file in Read-only mode
vim -R /tmp/linuxtopic
We can also use view command
view /tmp/linuxtopic
To edit existing file in vim
vi /tmp/linuxtopic
Thanks you !!
I hope this topic gave you all the information you needed. If you have any further questions or would like more detailed directions feel free to contact us using any of the following sources.We look forward to talking to you.