| Tutoriales | Vim |

Vim

Hi! I’m Danny 🙌🏽, and here I’ll share my experience with Vim, the text editor that every programmer and system administrator should master.

This is the central hub where you can search for anything about Vim: from basic commands to advanced configurations, keyboard shortcuts, plugins, and tricks to optimize your workflow.


What is Vim?

Vim is an advanced text editor, terminal-based, famous for its efficiency and speed.
It’s an evolution of Vi (created in 1976) and remains one of the most widely used editors for programming, server administration, and file editing on Linux, macOS, and Windows.


Advantages of using Vim

  • Fast and efficient: everything with the keyboard, no need for a mouse.
  • Highly configurable: through the .vimrc file and plugins.
  • Compatible with everything: Linux, macOS, Windows, even inside Docker or WSL.
  • Ideal for programmers and sysadmins.
  • Lightweight and always available: installed by default on most UNIX systems.

Getting started with Vim

How to open Vim?

vim file.txt

How to exit Vim?

  • :q → quit.
  • :wq → save and quit.
  • :q! → quit without saving.

Vim Modes

In Vim, you don’t type directly; you work in modes:

  • Normal → navigate, copy, paste, delete.
  • Insert → write text (i to enter).
  • Visual → select text (v to enter).
  • Command-line → run commands (: to enter).

Basic Vim Commands

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

Configuring Vim with .vimrc

The .vimrc file allows you to customize Vim according to your needs. Basic example:

syntax on
set number
set tabstop=4
set expandtab
set autoindent
set background=dark

Explanation:

  • syntax on → enables syntax highlighting.
  • set number → shows line numbers.
  • tabstop=4 → sets tab width.
  • expandtab → converts tabs to spaces.
  • autoindent → keeps automatic indentation.
  • background=dark → optimizes colors for dark themes.

With a manager like vim-plug, you can install extensions:

Example installation with vim-plug:

call plug#begin('~/.vim/plugged')

Plug 'preservim/nerdtree'        " File explorer
Plug 'vim-airline/vim-airline'   " Status bar
Plug 'junegunn/fzf.vim'          " Fuzzy finder
Plug 'tpope/vim-fugitive'        " Git integration in Vim
Plug 'sheerun/vim-polyglot'      " Multi-language support

call plug#end()

Advanced Vim Tips and Shortcuts

  • Move to beginning of line → 0
  • Move to end of line → $
  • Jump forward by word → w
  • Jump backward by word → b
  • Repeat last action → .
  • Search and replace across file: :%s/old/new/g

Vim is not just any editor: it’s a tool for those who seek real productivity in text editing. In this section of my site, you’ll find everything you need about Vim, from the basics to advanced configurations and plugins.

Bookmark this page as a reference, because I’ll be updating it constantly with new tutorials.

| Tutoriales | Vim |