DEV Community

Cover image for VIM Editor Tutorial for Beginners – Learn VIM the Easy Way
Khaled Md Saifullah
Khaled Md Saifullah

Posted on

VIM Editor Tutorial for Beginners – Learn VIM the Easy Way

VIM is one of the most powerful text editors available in Linux and Unix systems. It can be intimidating for beginners, but once you get the basics, you will realize how fast and efficient it is. This tutorial will walk you through VIM for beginners with simple examples so you can start using it confidently.


What is VIM?

VIM (Vi Improved) is an advanced version of the classic Vi editor. It is:

  • Pre installed on most Linux systems
  • Lightweight and super fast
  • Great for developers, sysadmins and power users

VIM is keyboard driven, meaning you can do everything without a mouse. This makes editing faster once you learn the commands.


How to Open and Exit VIM

To open a file in VIM:

vim filename.txt
Enter fullscreen mode Exit fullscreen mode

If the file does not exist, VIM will create it.

To exit VIM:

  • Press Esc (to make sure you’re not in insert mode)
  • Type one of the following:

    • :q → Quit
    • :q! → Quit without saving
    • :wq → Save and quit
    • :w → Save without quitting

VIM Modes Explained

VIM works in different modes:

  1. Normal Mode – Default mode (for navigation and commands)
  2. Insert Mode – For typing text (press i to enter)
  3. Command Mode – For running commands (press :)

👉 Quick switch:

  • i → Insert mode
  • Esc → Back to Normal mode
  • : → Command mode

Basic Navigation in VIM

In Normal Mode:

  • h → Move left
  • l → Move right
  • k → Move up
  • j → Move down

👉 Tip: You can also use arrow keys, but learning hjkl will make you faster.


Editing Text in VIM

Insert Text

  • i → Insert before cursor
  • a → Append after cursor
  • o → Open a new line below

Delete Text

  • x → Delete one character
  • dd → Delete a whole line
  • dw → Delete a word

Copy & Paste

  • yy → Copy a line (yank)
  • p → Paste after cursor

Undo & Redo

  • u → Undo
  • Ctrl + r → Redo

Searching and Replacing

Search

To search for a word:

/word
Enter fullscreen mode Exit fullscreen mode

Press n for next match, N for previous.

Replace

To replace "old" with "new":

:%s/old/new/g
Enter fullscreen mode Exit fullscreen mode

Example Workflow in VIM

  1. Open a file:
   vim hello.txt
Enter fullscreen mode Exit fullscreen mode
  1. Press i and type:
   Hello VIM!
   This is my first file.
Enter fullscreen mode Exit fullscreen mode
  1. Press Esc
  2. Save and exit:
   :wq
Enter fullscreen mode Exit fullscreen mode

Pro Tips for Beginners

  • Use vimtutor command in terminal for practice
  • Start with basic commands before advanced features
  • Don’t worry about speed at first accuracy matters

Conclusion

VIM may look difficult at the beginning, but with practice, you will become faster and more efficient than using any graphical editor. Start with small steps, practice the basics and soon you will love working with VIM.

👉 Try opening a file right now and test these commands. The more you practice, the easier VIM becomes.


Did this tutorial help you? Share your thoughts in the comments on dev.to.

Top comments (2)

Collapse
 
rkedlaya profile image
Raghavendra Kedlaya

Nice Article. It is very helpful to introduce and guide developers to use VIM or vi once a while. Those who work on Server side and those on mac systems find it convinient to use. It is the same vi basics since last 30+ years I am using. There are many more features, difficult to get outside of it. A closer match these days is notepad++
Just a few more here.
to add/replace text at the beginning of the line
:%s/^/new text/
to add/replace text at the end of the line
:%s/$/new text/
For navigation, if you need to find the matching brackets in a json text, use key %
to get to first line 1G, to get to last line G, to get character of the line $..
And so on...

Collapse
 
kmsaifullah profile image
Khaled Md Saifullah

Thank you for your lovely words and the great overview.