Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 36 ยท Getting Started

What Is Vim? Modal Editing Explained

Learn what Vim and Neovim are, why they use modes instead of menus, and how keyboard-first editing can make you faster. Includes a mode simulator.

Vim is a text editor that you control almost entirely from the keyboard. It runs in a terminal, starts in a fraction of a second, and works the same way on a laptop, on a server you reach over SSH, and inside a container. Neovim is a modern fork of Vim with a built-in Lua scripting engine and a more active plugin ecosystem. Almost everything you learn in this course works in both.

The thing that makes Vim feel strange at first is that it is modal. The same key does different jobs depending on which mode you are in. Once that idea clicks, Vim stops feeling odd and starts feeling fast.

This is a tool-usage course. Vim itself cannot run inside this website, so the examples show the keys you press and describe what happens. The runnable blocks are small JavaScript stand-ins that model the ideas (modes, motions, registers) so you can experiment. They are labelled as stand-ins every time.

Where Vim comes from

Vim means "Vi IMproved". It descends from vi, a visual editor written by Bill Joy in 1976 on top of the line editor ex. That history explains two things you will see all the time: the colon commands such as :w (they come from ex) and the odd choice of h j k l for movement (the keyboard Joy used had arrows printed on those keys).

Vim was written by Bram Moolenaar and released in 1991. Neovim started in 2014 to modernize the code base. It added an asynchronous job API, a built-in terminal, and later first-class Lua support. You will meet Neovim again in chapter 7.

Why modes?

Most editors have one mode: every key types a character, and commands need Ctrl or Alt chords or a mouse. Vim splits the job in two. In Normal mode every key is a command. In Insert mode keys type text. Because you spend most of your time reading and changing code rather than typing new code, Normal mode is the default.

The practical effect is that you press single keys for things that need chords elsewhere. w moves a word forward, dd deletes a line, u undoes. There is nothing to hold down, so your hands stay in place.

The main modes:

  • Normal: navigate and run commands. This is where you live.
  • Insert: type text (i, a, o enter it; Esc leaves).
  • Visual: select text, then act on the selection (v, V, Ctrl-v).
  • Command-line: type an ex command after :, a search after /.

Vim in four modes

Normal Keys are commands
Insert Keys type text
Visual Select, then act
Command-line Type : or /

Esc always brings you back to Normal.

1 / 2

A mode simulator (stand-in)

The block below is not Vim. It is a tiny state machine that reproduces the mode rules so you can see them. Edit the keys string and run it.

JS Mode state machine (stand-in)

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Notice that typing hello while in Insert mode does not change the mode, but the same letters in Normal mode would be commands (h moves left, e moves to the end of a word, l moves right, o opens a line and enters Insert mode).

The cost of not knowing the mode

The classic beginner accident is typing text while still in Normal mode. Each letter fires a command and your file changes in surprising ways. The fix is a habit, not a setting: when anything looks wrong, press Esc once or twice. It is harmless in Normal mode, and it leaves every other mode. If the screen still looks stuck, u undoes the last change.

A good status line shows the mode. Vim shows -- INSERT -- at the bottom by default (showmode), and Neovim distributions usually add a colored status line. Look at the bottom of the window before you type.

Keys are a language

Chapter 1 ends with the idea that makes Vim worth the effort: commands combine like a sentence. d means delete, w means a word, so dw deletes a word. d$ deletes to the end of the line. 3dw deletes three words. You learn a handful of verbs and a handful of nouns and get dozens of commands for free. The next lessons build that vocabulary, and the grammar lesson covers it directly.

A second stand-in: counting keystrokes

Efficiency in Vim is often about keystroke count. This stand-in compares typing in a mouse-driven editor with Vim for one small job: change the word color to colour four times on one line.

JS Keystroke arithmetic (stand-in)

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The numbers are rough, but the shape is real: Vim's . repeats the last change, so the second, third, and fourth edits cost two keys each.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In Vim, what does a key like d do in Normal mode?

    In Normal mode keys are commands. d is the delete operator and waits for a motion.
  2. 2. Which key leaves Insert mode?

    Esc returns to Normal mode from Insert, Visual and Command-line modes.
  3. 3. How is Neovim related to Vim?

    Neovim forked Vim in 2014 to modernize the code and add Lua, an async job API and a built-in terminal.
  4. 4. Why do h, j, k and l move the cursor?

    They sit under your right hand on the home row, and the terminal used when vi was written had arrows on those keys.

Summary

  • Vim is a keyboard-first, modal editor; Neovim is its modern fork with Lua.
  • Normal mode is the default and every key is a command; Insert mode types text.
  • Visual mode selects text; the colon prompt runs ex commands.
  • Esc is the universal way back to Normal mode.
  • Commands combine like sentences, which is where the speed comes from.

Next: Installing Vim and Neovim