What is Vim and How to Use It: A Complete Guide for Beginners

DJC > Tutorial

| Vim |

If you’ve ever worked with Linux or programming, you’ve probably heard of Vim, one of the most powerful and versatile text editors out there. Although its interface can seem intimidating at first, Vim is an extremely efficient tool once you master it.

In this complete guide, you’ll learn what Vim is, how to install it, its main modes, and the basic commands to start using it like a pro.


What is Vim?

Vim (Vi IMproved) is an enhanced version of the classic Vi text editor, created in 1991 by Bram Moolenaar.
It’s designed to be fast, lightweight, and fully controllable from the keyboard, without needing to use the mouse.

It’s mainly used to edit source code or configuration files on UNIX, Linux, and macOS systems, although it’s also available for Windows.

Advantages of Vim:

  • Speed: everything is done from the keyboard, no mouse needed.
  • Productivity: allows automation through macros and scripts.
  • Highly customizable: thousands of plugins available.
  • Lightweight and stable: works even on servers without a graphical interface.

How to Install Vim

On Linux

sudo apt install vim
````

*(for Debian-based distributions, such as Ubuntu)*

#### On macOS

```bash
brew install vim

On Windows

You can download it from the official site: https://www.vim.org/download.php


Vim Modes

Vim doesn’t work like traditional editors. It has operation modes that change how the keyboard behaves:

Mode Description How to enter
Normal Navigate and execute commands When Vim starts
Insert Type text i
Visual Select text v
Command Run advanced commands :

Example:

  • In normal mode, press i to enter insert mode.
  • Type some text.
  • Press Esc to return to normal mode.

Basic Vim Commands

Here’s a list of the most useful commands for beginners:

Action Command
Enter insert mode i
Save file :w
Quit Vim :q
Save and quit :wq
Quit without saving :q!
Copy a line yy
Paste p
Delete a line dd
Search text /word
Undo u

Tip: If you get lost, press Esc several times until you’re back in normal mode.


How to Open and Close Files

  • Open a file:

bash vim file.txt

  • Open multiple files:

bash vim file1.txt file2.txt

  • Close Vim:

  • Save and quit: :wq

  • Quit without saving: :q!

Customization and Plugins

Vim can be customized through the configuration file ~/.vimrc. For example:

syntax on
set number
set autoindent
set tabstop=4

There are also plugin managers such as:

  • vim-plug
  • Vundle
  • Pathogen

Example with vim-plug:

call plug#begin('~/.vim/plugged')
Plug 'preservim/nerdtree'   " File explorer
Plug 'junegunn/fzf.vim'     " Fast search
call plug#end()

Tips and Best Practices

  • Learn the movement keys (h, j, k, l) to move without the mouse.
  • Use / to search within the file.
  • Record macros with q + letter to repeat actions.
  • Integrate Vim with Git and other development environments.

Vim may seem complicated at first, but it’s a powerful tool for developers and system administrators. With practice, you’ll discover that it’s one of the fastest, most flexible, and efficient editors available.

If you’re just starting out, spend a few minutes each day practicing the basic commands. In no time, you’ll be editing text faster than ever.


DJC > Tutorials


DJC > Tutorial