Getting started with Vim: A Complete Beginner’s guide

Shumanisimeli
3 min readOct 26, 2023

--

If, like me a few months ago, you find yourself in a situation where you have to use Vim for the first time, this article is for you. In this guide, we’ll cover the basics to help you get started and become more confident in using Vim.

What is Vim?

Vim can be described as a free Unix-like text editor that comes pre-installed on most Linux and MacOS systems. You can also easily install Vim using the terminal. Vim is an improved version of the Vi text editor, hence its name, which stands for “Vi improved”. It is commonly used for writing code, scripts, and editing or creating text documents. One important thing to remember is that Vim doesn’t rely on the mouse; instead, it is operated primarily using the keyboard. Vim consists of two main modes:

1. Normal mode: This is the starting mode, where you can navigate and manipulate text, including copy and paste.

2. Insert mode: This mode allows you to edit and insert text. You can switch into this mode with the ‘i’ key and leave it with the ‘Esc’ key.

Using Vim

Opening vim:
You can open the Vim text editor by typing ‘vim’ followed by the name of the file in the terminal. To quit Vim, you can use several commands, which are case-sensitive:

  • ‘:wq’: Saves changes and then quits.
  • ‘:q!’: Quit without saving changes.
  • ‘:q’: Quit if there are no changes.

You can also temporarily exit Vim by pressing ‘Ctrl+Z’ and re-enter it with the ‘fg’ command.

Basic navigation

To navigate in Normal Mode, you can use arrow keys for movement. Alternatively, you can use letter keys: ‘h’ (left), ‘j’ (down), ‘k’ (up), and ‘l’ (right).

Navigation shortcuts and commands

Vim offers various shortcuts and commands for efficient text navigation:

  • To move to a specific line, you can type a number followed by ‘G’. For example, ‘4G’ moves to the fourth line.
  • ‘G’ without a number moves to the very end of your text.
  • ‘$’ moves you to the end of the current line.
  • ‘^’ moves to the beginning of the current line.
  • ‘w’ moves to the beginning of the next word.
  • ‘b’ moves to the beginning of the previous word.

Editing and manipulating text

One downside of using Vim is that it doesn’t show line numbers automatically. However, you can temporarily enable them using the ‘:set number’ command. Here are a few commands for editing text:

  • ‘dd’: Deletes the current line. You can add a number before the command to delete multiple lines.
  • ‘yy’: Copies (yanks) the current line. You can add a number before the command to copy multiple lines.
  • ‘p’: Pastes the copied text.
  • ‘u’: Undoes any changes made to the text.
  • ‘Ctrl+R’: Redoes a change.

Conclusion

Vim may seem challenging a beginners, but with regular practice, it can become a valuable resource for various text editing needs. For more information or assistance, you can type ‘:help’ in normal mode, visit the Vim website (https://vim.rtorr.com/), or use online forums like Stack Overflow. With patience and practice, you’ll become proficient with this powerful text editor. Enjoy your journey.

--

--