Shell Scripting Lesson 2 - Basic Commands about Vim Editor

I have posted  my first post about Shell Scripting tutorial Series. It is about Basic Shell Commands where we want to use throughout this course. Now I am going to teach you about Some basic vim commands.

This Commands are very useful. Because I am going to use vim editor as my default Shell Script Editing Tool.

OK...That's Enough ! Let's Turn to Our Tutorial..... !


Vim is the enhanced editor of vi editor in Unix Systems.

Lets Create a text file Using vim editor. Open a Terminal in your UNIX system.Type following command in your terminal.
vim filename.txt

Type a file name with its extension where you want to create. As an example if you want to create mytext.txt file, type vim mytext.txt in your Linux Terminal.

You have opened a text file.

Press i key in your keyboard to go to the insert mode of vim editor.

Add some text into your Text File. After adding some text into your text file, you have to save your text file. It is quite different from Normal Text File saving in Text Editors.

For Save your Text File, Press ESC Key Then Type : (colon). Finally press w letter in your keyboard.

When you press Escape key, Insert mode is changed to command Mode. Then you type command after the colon.

:w is to write file into disk.
:wq Save and Close the text file.

If you want to close without saving the file Press :q!

In Command Mode, Press u key to undo your changes.To search some text in vim editor press / key in Command Mode and Type what you want to search. Press n key to search forwards for next occurrence. Press N to Backwards.

If you want to go to Last line of file, Press G (Shift+G)
If you want to got First Line of file, Press gg  (Press g key Twice.)

 That's All for Today... ! See you in Next Tutorial !

Note : If you have some doubts about my Tutorial, Please drop a comment.

0 comments:

Post a Comment

Ask anything about this Tutorial.