Feb.08

Create and Edit file using Vim editor

‘vim’ includes many features to edit files, Here i have share simplest way to create and edit file in vim editor in linux shell environment.
Using ‘vim’ to create and edit a file

#1  Log into your server via SSH.
#2 Navigate to the directory location you wish to create the file, or edit an existing file.

#3 Type in vim followed by the name of the file. For example, if you wish to create (or edit) a new file named test.html, run the following:

[server]$ vim test.txt

The 'vim' editor will appear but we must change file mode to insert text. 
[ confusing at first because you cannot type into the file yet:]


Click the letter 'i' on your keyboard to enter INSERT mode in 'vim'.
It now shows -- INSERT -- on the bottom left:

 

Now we  can add edit into file.

 

#4 When finished editing the file, click the ESC key.

This takes you out of INSERT mode and — INSERT — disappears from the bottom left of your terminal.

 

 

#5 To save the file, type in a colon followed by wq. For example:

:wq

 

#6 Click ‘Enter’ to save.

Share this Story:
  • facebook
  • twitter
  • gplus

Leave a comment

Facebook Comment