---
title: "VIM Text Editor (Basics)"
description: "Vim is the successor of the vi terminal text editor with a long list of powerful features. Short for “Vi IMproved,” Vim is sometimes pre-installed on popular, staple Linux distributions such as..."
url: https://www.inmotionhosting.com/support/server/ssh/vim/
date: 2021-02-05
modified: 2023-12-22
author: "InMotion Hosting Contributor"
categories: ["SSH and Root Access"]
type: post
lang: en
---

# VIM Text Editor (Basics)

[**Vim**](https://www.vim.org/) is the successor of the [**vi**](https://www.vim.org/viusers.php) terminal text editor with a long list of powerful features. Short for “Vi IMproved,” Vim is sometimes pre-installed on popular, staple [Linux distributions](https://www.inmotionhosting.com/support/server/linux/understanding-linux-operating-systems/) such as CentOS and Debian. For others including [Linux Mint](https://linuxmint.com/), you might instead have the original **vi** or **vim.tiny**, a slimmed down variant of Vim excluding dozens of advanced, yet less commonly used features.

In an earlier article, we compared [Vim versus Emacs](https://www.inmotionhosting.com/support/edu/emacs/choosing-emacs-vs-vim/) and how to port Vim key bindings into Emacs. Power users looking to move away from [Nano](https://www.inmotionhosting.com/support/server/ssh/how-to-edit-files-using-nano/) in the command-line interface (CLI), or [Secure Shell (SSH)](https://www.inmotionhosting.com/support/server/ssh/what-is-shell-access/), may have found a resolution with Vim.

Below we’ll cover the basics of:

- [How to Use Vim](#use)
  - [Normal Mode](#normal)
  - [Insert Mode](#insert)
  - [Replace Mode](#replace)
  - [Visual Mode](#visual)
  - [Command Mode](#command)
- [How to Configure Vim](#config)
- [Vim Tutorials](#tutorial)
  - [Vimtutor](#vimtutor)
  - [Vim Cheat Sheet](#rtorr)
  - [VIM Adventures](#vimadventures)
  - [The Linux Command Line Book](#book)

Before using Vim, be sure that you know how to [navigate the command line structure in SSH](https://www.inmotionhosting.com/support/server/ssh/navigate-command-line/) so that you can get to the right files.

## How to Use Vim

[SSH into your Linux server](https://www.inmotionhosting.com/support/server/ssh/how-to-login-ssh/). To edit or create a file, type the following command: 

vim filename

![Empty text file in Vim](https://www.inmotionhosting.com/support/wp-content/uploads/2021/02/vim-empty.png)

Next, we’ll cover the multiple Vim *modes*: insert, replace, visual, command, and normal.

### Normal Mode

This is the default mode when you first open a file with Vim. In this mode, you can move the cursor with the arrow keys or Vim key bindings.

Move left: ⬅ or H

Move down: ⬇ or J

Move up: ⬆ or K

Move right: ➡ or L

**Navigate words:**

Move to start of previous word: B

Move to start of previous word before a whitespace: Shift+ B

Move to end of word: E

Move to end of word before a whitespace:  Shift + E

Move to start of next word: W

Move to start of next word after a whitespace: Shift + W

**Navigate lines:**

Move to the start of the current line: 0

Move to the end of the current line: $

**Copy, cut, and paste:**

Copy text: Y

Copy a line: `yy`

Cut text: D

Cut a line: `dd`

Paste text: P

### Vim Insert Mode

This is the most common mode as it allows you to insert text in a document. To enter this mode: 

Press I or Insert to insert text at the cursor location.

Press O to create a new line below the cursor location and insert text there.

While in Insert Mode, the bottom of the terminal will read `-- INSERT --`.

Press Esc to return from to Normal mode.

### Replace Mode

This mode allows you to replace individual or multiple characters at once.

Press R to replace a single character in the file. There will be an `r` in the lower-right corner until you replace a character.

Press Shift + R to replace multiple characters or lines within the file. Meanwhile, the bottom of the file will read `-- REPLACE --`.

### Visual Mode

This mode selects text starting from the current cursor position. This may be a more [accessible](https://www.inmotionhosting.com/support/website/6-ways-to-improve-website-accessibility/) method for easily copying text for some users.

Press V to select individual characters starting from the current cursor position. At the bottom you’ll see
`-- VISUAL --`.

Press Shift + V to select full lines including the current cursor position. At the bottom you’ll see
`-- VISUAL LINE --`.

### Command Mode

Commands start with `:` and are executed with Enter. Just as with returning to Normal mode, you can exit out by pressing Esc.

Save changes: `:w`

Exit Vim without saving changes: `:q!`

Save changes and exit Vim: `:qw`

Save changes and exit Vim, enter one of the following: `:x` or `:wq`

Quit Vim without saving the file, enter `:q`

To force an action, add `!` to the end of the command. For example, `:q!` or `:wq!`.

Open a second document in the terminal with a vertical split:

:vsplit path-to-file

## How to Configure Vim

Sysadmins can make system-wide changes to Vim environments within the system vimrc files (/etc/vim/vimrc or /usr/share/vim/vimrc). Users can customize their personal Vim environment by creating a `~/.vimrc` file. We’ll share some notable features you can uncomment or add in system or personal vimrc files respectively.

Enable syntax highlighting: 

syntax on

Show matching brackets while coding:

set showmatch

Enable mouse usage in all modes: 

set mouse=a

## Vim Tutorials

Want to learn more about Vim? Prefer hands-on training? Check out these resources below for interactive learning and advanced features.

### Vimtutor

Vimtutor works as an extension of `man vim` with lessons to walk you through how to use Vim commands. Start the tutorial with the command `vimtutor`.

### Vim Cheat Sheet

Check out the [rtorr Vim cheat sheet](https://vim.rtorr.com/) for when you’re on the go. It’s available in multiple languages and on [GitHub](https://github.com/rtorr/vim-cheat-sheet). [DuckDuckGo](https://www.inmotionhosting.com/support/news/search-with-duckduckgo/) users can find it quickly by searching “vim cheat sheet.”

### VIM Adventures

To learn more about using the VIM text editor, you can try the [VIM Adventures](https://vim-adventures.com/) educational game. The full version requires a paid subscription. However, you can play the free trial in your browser. 

### The Linux Command Line Book

One of our technical support representatives recommended [The Linux Command Line](https://linuxcommand.org/tlcl.php) book for it’s Vim coverage. This is just one of many ways to [learn Linux](https://www.inmotionhosting.com/blog/5-free-ways-to-learn-linux/).

**Scalable VPS Infrastructure, Fully Managed**

When shared hosting can’t handle your traffic, VPS delivers dedicated resources that scale with demand. Our team manages the technical complexity while you manage your business.

![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)NVMe Storage    ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)High-Availability    ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)Ironclad Security    ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)Premium Support

[VPS Hosting](https://www.inmotionhosting.com/vps-hosting?mktgp=t&irgwc=1&affiliates=5001860&utm_campaign=Jumbotron&utm_source=supportcenter&utm_medium=cta&utm_term=vps-cta2)
