Quick Start

Welcome to the QuickStart guide for Vim. This guide will help you get the bare bones knowledge of using Vim and will get you to the point where you can embark on the long but fun, journey to using Vim as your main text editor!

Installation

Eric

MacOS

Using homebrew, you can install the latest version of Vim with brew install vim, though an older version comes pre-installed on MacOS if you don't wish to use homebrew.

Windows

If you are on a Windows machine, navigate to vim.org, downloads, and select your version. Afterwards, it will be accessable from the cmd Terminal, or if chosen in the installation, can be launched from the Desktop Icon.

Linux

Fedora

sudo dnf install vim

Arch Linux

sudo pacman -S vim

Debian/Ubuntu

sudo apt install vim

Verify Installation

Verify that Vim is installed by opening a terminal and running vim. If you see something like this, you are good to go! Now you can exit Vim by typing :q.

Vim Screenshot

A Quick Adventure - Making A Todo File

Creating a New Todo List

Tyler

Creating a new file with vim is really simple just type:

vim todo.txt

Whenever you pass a file that doesn't exist vim creates it for you and opens it up for editing.

Tyler

Vim does not support the usage of a mouse so movement of the cursor is handled entirely with the keyboard. The basic movements of the cursor are as follows:

Command Description
h (←) Move the cursor left one character
j (↓) Move the cursor down one line
k (↑) Move the cursor up one line
l (→) Move the cursor right one character

Adding a Todo

Eric

Now that you have opened a file in Vim, it's time to insert text. For now, press the i key to enter into Insert Mode. More details on the different modes will be covered a little further on. For now, lets practice adding some text to Vim.

Inserting text works just like any other text editor, so try and insert some text, following this format:

TODO List

This will probably end up with something to the likes of:

My Todos
- [ ] Eat Vegetables
- [ ] Take a Nap
- [ ] Learn Vim

A Quick Aside: Normal vs Insert Mode

Logan

Insert mode, used to actually type text into the document, can be accessed by pressing i. To exit this mode, press the ESC key.

For now, think of Normal Mode as the mode to move the text cursor around, and Insert Mode as how to actually insert text into the document (this will be further explained in Understanding Vim).

Saving

Authored by Alaina D

Once you have added text to a file (see "Adding a Todo" if you are not sure how to insert text), you will want to save the file for later editing.

In Vim, there are three common ways to save a file:

Before you attempt any of the above commands, hit ESC (the "escape" key) to make sure Vim is in Normal mode. You should see a blank line in bottom of your terminal (hint: if the bottom of your terminal says "-- INSERT --", you are not in Normal mode).

The following is a screenshot of Vim in normal mode:

Vim Screenshot

Once Vim is in normal mode, you can enter any of the previously mentioned "save" commands (:w, :x, or :wq), followed by the ENTER key.

Note: These commands are case-sensitive (the letters in each command must be lower-case).

Using :w

The command :w will save (write) the file that you are currently editing. If you use :w to write (save) your file, your file will remain open in Vim. This command is great for saving a file that you would like to continue editing.

Using :x

The command :x will save (write) the file that you are currently editing. If you use :x to write (save) your file, your file will only be saved if changes have been made to the file. This command will not change the modification timestamp of the file if you have not made changes to the file after opening it. If you use :x to save your file, Vim will exit when you hit enter.

Using :wq

The command :wq will save (write) the file that you are currently editing, and will exit Vim after the file is saved. If you want to save and quit Vim all in the same command, :wq should be your weapon of choice.

NOTE: :wq is not the only command to use to exit Vim--it is merely a convenient way to save a file and exit Vim at the same time.

Exiting

Trevor

The Command for exiting vim is :q. If the file has been edited since it was opened, :q will not work, instead giving a warning about unwritten changes. To bypass this, you can add an ! to the command, making it :q!, which will quit without saving.

Reopening The File

Tyler

After saving (using :w, :x, :wq, etc.), re-open the todo file to prove that the changes made have been saved:

vim todo.txt

Mark A Todo As Done

Tyler

Navigate the cursor between the brackets of the task you want to mark as done and enter Insert mode i.

Mark the task done by entering a capital X.

Then, enter Normal mode by pressing the Escape key, press j to go down a line to the next todo, and mark it as done the same way.

Vim Screenshot

Delete A Todo

Tyler

One way to remove a todo from the list is to delete the entire line. To do this, get into Normal mode and navigate the cursor to the line you want to delete. Then, press the d key twice: dd, to remove the line.

Vim Screenshot

Further Understanding Vim

Amazing! You've made it this far. Let's take a look at how you can do more by understanding Vim.