Get Started With Vim

marwan01 profile image Marouen Helali Originally published at Medium ・3 min read

You do not need to be a command line wizard to be able to use Vim. Using Vim consists in three simple steps: opening Vim, making the necessary text edits, then saving and exiting.

Alt Text

1. Opening Vim

vim helloworld.txt

Using the vim command followed by a file name will result in opening that file in the vim editor. If that file does not already exist in your current directory, it will be created.

Alt Text

Result of opening a new file using vim

In this case, we see [New File], because I did not have a helloworld.txt already present in my directory, so I am creating it.

2. Using Vim

In order to go any further, we need to get a grasp on how Vim generally works. These are the key concepts you need to remember:

  • Vim is a text editor (just like VSCode) that runs in your terminal.
  • Once you open Vim, you get into an interactive mode.
  • IMPORTANT: Vim has multiple modes.
  • IMPORTANT: Vim operates on commands.
  • Vim is extremely configurable.

Theory behind modes & commands:

When you first open Vim, you are in NORMAL mode (otherwise knows as MASTER mode) . This is like your home base. You always want to make sure you are in NORMAL mode before you execute any commands. Press i to jump to INSERT mode. Note that once you are in INSERT mode, all your keystrokes will result in text. In other words, you will not be able to enter any commands. In order to do so, you will need to go back to NORMAL mode, which is easily achievable by pressing the <ESC> key.

Feel free to reference the diagram below. Keep in mind that VISUAL mode is simply another mode, just like INSERT mode, accessible by pressing v.

Alt Text

Source: https://github.com/nilp0inter/Vim-for-Muggles

Every Vim command starts with a colon : and is followed by a special keyword. Remember that you can only execute commands in NORMAL mode.

Now that you understand the concept of modes & commands, go back to your terminal, and add some text to your file while in INSERT mode:

Alt Text

3. Closing Vim

To wrap this up, let’s make sure to have stackoverflow’s most popular question answered. Numerous people (including me) end up opening Vim by mistake, and not knowing how to exit it (in my case, it was after a git commit command without a -m message).

With the knowledge you have now, this is simply a matter of executing the right command. make sure you are in the NORMAL mode by pressing <ESC> and use the adequate :q command from the list below to quit Vim.

:q - no changes were made
:q! - trash all changes
:wq - save the changes

Alt Text

Using the :wq command to write changes and quit Vim.


  1. Open file using Vim: vim
  2. INSERT mode: press i
  3. NORMAL mode: <ESC>
  4. Save Changes & Exit: :wq
  5. Exit Without Saving Changes: :q!

If you think you got a handle on the 5 steps from the recap above, then congratulations 🎊 you are now a Vim user!


Although this article might help you get your feet wet with Vim by accomplishing basic text editing operations quickly via the terminal, it only encompasses about 1% of Vim’s potential. If you want to learn more, vimtutor is a fantastic built-in command that will pull up important Vim lessons on your terminal. You can also access it on the web via vimtutor.

Still trying to grow your Vim knowledge? Checkout these resources:

🌐 Official Website: https://www.vim.org/
πŸŽ₯ Youtube Playlist: https://www.youtube.com/watch?v=_NUO4JEtkDw&list=PLMHNm2pfuJiuJUOSpIyGJHpk3B7PCvpBw
🌐 Wikipedia: https://en.wikipedia.org/wiki/Vim_(text_editor)
πŸ“œ My personal favorite Vim Cheat Sheet: https://devhints.io/vim
🌐 Tutorial: https://www.tutorialspoint.com/vim/vim_quick_guide.htm
🎨 Personalize Vim by editing .vimrc: https://dougblack.io/words/a-good-vimrc.html

Original Source: https://medium.com/swlh/getting-started-with-vim-3f11fc4f62c4

Posted on by:

marwan01 profile

Marouen Helali


SRE at Bayer πŸ€– β€’ Ex Software Developer πŸ’» β€’ Cloud Enthusiast β˜οΈβ€’ Freelance Writer πŸ“– β€’ Git Guru πŸ§˜β€’ DevOps Fanatic βš™οΈ β€’ Marathon Runner πŸƒβ€’ Scuba Diver 🐠


Editor guide