CBSE 2026 results are out, Mukul scored a perfect 100/100 in Computer ScienceSee all toppers →

KwickAcademy Course Topics · 7 min · free

Vim modes and commands

7 min1 KwickClipsFull text belowFree
Next lesson →Kajal Ma'am (MCA), teaching since 2004Remembered in this browser

Learn Vim: Normal, Insert, Command-line and Visual modes, i a o, moving the cursor, x dd yy p u, :w :q :wq :q!, and search and replace. Vim opens in Normal mode; press i to type and Esc to go back.

Follows the syllabus of: GSEB Std 11 Computer Studies

On screen in this lesson

What is Vim?

A text editor that runs in the terminal
Vim means Vi IMproved
Works without a mouse, only keys
Found on almost every Linux system

The modes of Vim

ModeUsed forEnter with
Normalmove, delete, copyEsc
Inserttyping texti, a or o
Command-linesave, quit, search: or /
Visualselecting textv

Entering Insert mode

KeyStarts typingExample use
ibefore the cursoradd a letter
aafter the cursoradd at word end
oon a new line belowadd a new line
Aat end of lineadd a full stop

Moving the cursor

KeyMovesTip
h j k lleft down up rightarrows also work
0 and $line start and endsame line
gg and Gfirst and last linewhole file
5Gto line 5any number

Editing in Normal mode

KeyDoesExample
xdelete a characterfix a typo
dddelete a line3dd deletes 3
yycopy a lineyank means copy
ppaste belowafter dd or yy
uundoCtrl+R redoes

Save and quit commands

CommandDoesWhen
:wsavekeep working
:qquitno unsaved changes
:wqsave and quitmost common
:q!quit, do not savediscard changes
ZZsave and quitNormal mode

Quick answers

In Insert mode you type :wq and press Enter. Is the file saved?

No. It is typed as text; press Esc first.

What does :q! do?

Quits without saving.

KwickClips from this lesson

Short clips, one idea each. Good for revision the night before.

The full lesson, in text

Hello students, welcome to Kwickprep. You opened Vim, typed your name, and strange things happened. Then you could not even quit! Why? Because Vim has modes. Today we will learn its modes and the commands to type, edit, save and quit.

First, what is Vim? Vim is a text editor, a program to write and change text files, and it runs in the terminal. Its name means Vi Improved, because it is an improved version of the older vi editor. Everything is done with keys, so no mouse is needed. It is found on almost every Linux system, including servers.

To open a file, type vim followed by the file name. If notes dot txt does not exist, Vim opens an empty screen and creates the file when you save. On many systems, typing vi also opens Vim. The screen shows the text, with tilde signs on empty lines.

Vim has different modes, and each key means something different in each mode. Normal mode, also called command mode, is for moving, deleting and copying, and Esc brings you here. Insert mode is for typing text, and you enter it with i, a or o. Command-line mode, also called last line mode, is for saving, quitting and searching, and starts with colon or slash. Visual mode is for selecting text, and starts with v.

Let us see how the modes connect. Vim always opens in Normal mode. If you need to type, press i for Insert mode, then press Esc to come back. If you do not need to type, simply stay in Normal mode. From Normal mode, type colon to give a command like save or quit.

There are several keys to start typing, and each puts the cursor in a different place. Small i starts typing before the cursor. Small a starts typing after the cursor. Small o opens a new empty line below and starts typing there. Capital A jumps to the end of the line, which is handy for adding a full stop.

In Normal mode, we move the cursor with keys. H, j, k and l move left, down, up and right, and arrow keys also work. Zero goes to the start of the line, and dollar goes to the end. Small gg goes to the first line of the file, and capital G goes to the last line. A number before capital G, like five G, goes to line five.

Now the editing keys, all used in Normal mode. X deletes the character under the cursor. Dd deletes the whole line, and three dd deletes three lines. Yy copies a line, and Vim calls copying yanking. P pastes the deleted or copied text below the cursor line. U undoes the last change, and Ctrl+R redoes it.

These commands start with a colon and end with Enter. Colon w writes, which means saves, the file. Colon q quits, but only if there are no unsaved changes. Colon w q saves and quits, and it is the one you will use most. Colon q with an exclamation mark quits without saving and throws away the changes. Capital ZZ in Normal mode also saves and quits.

Vim can also find and replace text. Slash followed by a word searches forward, and n jumps to the next match. Question mark followed by a word searches backward, and capital N goes to the previous match. Colon percent s, slash old, slash new, slash g, replaces every old word with the new word in the whole file.

Let us fix a real mistake. The file marks dot txt says Riya twenty eight, but her marks are eighty two. Place the cursor on the digit two, and press x to delete it. Now it says Riya eight. Press a to type after the eight, type two, and press Esc. Now it says Riya eighty two, so type colon w q to save and quit.

Pause and predict. You are still in Insert mode. You type colon w q and press Enter. Is the file saved? No, the letters colon w q are simply typed into your text, because Insert mode treats keys as text. Press Esc first, then type colon w q.

Here are mistakes every beginner makes. Typing text in Normal mode runs random commands, because letters like d and x are commands there. Forgetting to press Esc before colon w q types it into the file. Using colon q with unsaved changes shows error E thirty seven, no write since last change. When you feel lost, press Esc twice to return safely to Normal mode.

Let us revise what we learned today. Vim always opens in Normal mode. Press i, a or o for Insert mode, and Esc to come back. In Normal mode, x, dd, yy, p and u delete, copy, paste and undo. Colon w saves, colon q quits, colon w q does both, and colon q exclamation mark discards changes. Slash word searches, and n finds the next match.

Courses that teach this

CourseUnit
GSEB Std 11 Computer StudiesVim Editor and Basic Scripting

Voice-over in this lesson is AI-generated. The script is written and checked by Kajal Ma'am. Boards can revise a syllabus mid-year, so confirm anything you plan around against the official board circular. Keep your passwords, OTPs and ID numbers to yourself — we never ask for them. To reach Kajal Ma'am, use the WhatsApp button; sharing your number there is how we call you back.

Free to watch, no sign-up. Live classes with Kajal Ma'am are the paid course; these lessons stay free either way.

Want a plan that actually fits your board dates?

Ask Kajal Ma'am directly, 20+ years teaching computer science. Free demo class first, no payment.

Talk to Kajal Ma'am on WhatsApp

Or see the Class 12 Computer Science course →

Studying outside India?

We coach CBSE, IGCSE & international students across the globe, one-to-one, in your local time zone.

Visit International →