0.2 — Installing and Launching Vim

0.2 — Installing and Launching Vim#

Before we can start learning Vim, we need to have it installed on our system. In this lesson, we’ll cover installation on major operating systems and how to launch Vim for the first time.

Checking if Vim is Already Installed#

Vim (or at least vi) is pre-installed on most Unix-like systems. Open your terminal and type:

vim --version

If Vim is installed, you’ll see version information and a list of features. If not, you’ll see a “command not found” error.

You can also check for the basic vi editor:

vi --version

Installation by Operating System#

macOS#

macOS comes with a basic version of Vim pre-installed. However, you may want a more feature-rich version:

Using Homebrew (recommended):

brew install vim

For Neovim (modern fork):

brew install neovim

After installation, you may need to restart your terminal or add the Homebrew bin to your PATH.

Linux#

Most Linux distributions include Vim, but you can install or upgrade it:

Debian/Ubuntu:

sudo apt update
sudo apt install vim

Fedora:

sudo dnf install vim

Arch Linux:

sudo pacman -S vim

For Neovim:

# Ubuntu/Debian
sudo apt install neovim

# Fedora
sudo dnf install neovim

# Arch
sudo pacman -S neovim

Windows#

Using Winget:

winget install vim.vim

Using Chocolatey:

choco install vim

Using Scoop:

scoop install vim

Manual Installation: Download the installer from vim.org/download.

For WSL users: If you use Windows Subsystem for Linux, follow the Linux instructions within your WSL distribution.

Vim vs Neovim#

You’ll often hear about Neovim as an alternative to Vim. Here’s a quick comparison:

FeatureVimNeovim
CompatibilityOriginal99% Vim-compatible
ConfigurationVimscript, Lua (9.0+)Lua preferred
Modern FeaturesAvailableBuilt-in LSP, Treesitter
CommunityMature, stableActive, modern

For this course, we’ll focus on concepts that work in both. The commands and techniques you learn will transfer seamlessly between Vim and Neovim.

Launching Vim#

Basic Launch#

To launch Vim with an empty buffer:

vim

To open a specific file:

vim filename.txt

To open multiple files:

vim file1.txt file2.txt file3.txt

Launching Neovim#

If you’re using Neovim, replace vim with nvim:

nvim
nvim filename.txt

Command-Line Options#

Vim has many command-line options. Here are the most useful:

OptionDescription
vim filenameOpen a file
vim +10 filenameOpen file and jump to line 10
vim +/pattern filenameOpen file and search for pattern
vim -R filenameOpen file in read-only mode
vim -d file1 file2Open files in diff mode
vim -o file1 file2Open files in horizontal splits
vim -O file1 file2Open files in vertical splits

Your First Vim Session#

Let’s launch Vim and understand what we see:

  1. Open your terminal
  2. Type vim and press Enter

You should see something like:

~
~
~                    VIM - Vi IMproved
~
~                    version 9.0
~                    by Bram Moolenaar et al.
~
~           Vim is open source and freely distributable
~
~                  type  :help iccf<Enter>       for information
~                  type  :q<Enter>               to exit
~                  type  :help<Enter>            for on-line help
~                  type  :help version9<Enter>   for version info
~
~

Understanding the Screen#

Important: You’re Now in Normal Mode#

When Vim launches, you’re in Normal mode. This is crucial to understand:

Don’t panic! In the next lesson, we’ll cover the survival basics, including how to safely exit Vim.

Getting Help#

Vim has an extensive built-in help system:

:help           " Open help
:help topic     " Help on specific topic
:help :w        " Help on the :w command
:help i         " Help on the i command
:q              " Close help window

The help system uses hyperlinks—press Ctrl-] on a highlighted topic to jump to it, and Ctrl-o to jump back.

Practice Exercise#

  1. Open your terminal
  2. Check your Vim version: vim --version
  3. Launch Vim: vim
  4. Look at the welcome screen
  5. Type :q and press Enter to exit

Congratulations! You’ve successfully launched and exited Vim. In the next lesson, we’ll cover the essential survival commands you need to know.

Summary#

TaskCommand
Check Vim versionvim --version
Launch Vimvim
Open a filevim filename
Open file at line Nvim +N filename
Open help:help
Exit Vim:q