---
title: "Understanding Vim Modes and Block Selection Magic"
url: "https://courses.osherove.com/courses/vim-hates-you/understanding-vim-modes-and-block-selection-magic.md"
canonical: "https://courses.osherove.com/courses/vim-hates-you/understanding-vim-modes-and-block-selection-magic/"
tags: []
author: "Roy Osherove"
description: "Lesson 7 of 26 in Vim Hates You (Get Somewhat productive in an hour or so), 6:13. Free video by Roy Osherove."
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Understanding Vim Modes and Block Selection Magic

1. [Courses](https://courses.osherove.com/#courses)
2. [Vim Hates You](https://courses.osherove.com/courses/vim-hates-you/)
3. Get Somewhat productive in an hour or so

Lesson 7 of 26

Duration: 6:13 [Watch on YouTube](https://www.youtube.com/watch?v=C_Pe9xlR-WY)

## In this lesson

Roy explains that each Vim mode changes how the keyboard behaves: normal or navigation mode is the default, and insert mode can be entered in several ways, such as i, o, Shift-O and Shift-I. He then shows the three selection modes: v for characters, Shift-V for whole lines and Ctrl-V for block (column) selection. In [block selection](https://www.youtube.com/watch?v=aaCGJCJPSjA "Vimming - Natural Selection (YouTube)") he changes a column of words with c, inserts text before each line with Shift-I and replaces a selection with r, and each change applies to all the selected lines.

## Transcript

979 words

[\[00:08\]](https://www.youtube.com/watch?v=C_Pe9xlR-WY&t=8s) Let's talk about Vim modes. Vim has different modes and each mode changes how the keyboard behaves. Basically, the default mode that Vim starts at is normal mode or navigation mode. In here, you can use a jk W to move words and and a bunch of other navigation that I'm going to be sharing the shortcuts to in a different video. We can then move from navigation mode to insert mode. So by clicking I am now able to just type. Able to just type. And you can get into insert mode by in many ways.

[\[00:42\]](https://www.youtube.com/watch?v=C_Pe9xlR-WY&t=42s) For example, from navigation mode to insert mode at the line above what you are by creating a line just above. You press shift O. And now you're in insert mode in the line above by pressing small O. We are creating a line below and are now in insert mode. By for example pressing shift I we are moving to the beginning of the line and now we are in insert mode. So there are many ways to go into insert mode and saving keystrokes and I'm going to share a whole video about

[\[01:21\]](https://www.youtube.com/watch?v=C_Pe9xlR-WY&t=81s) Jumping into insert mode in many different ways. So these are the first two modes simple navigation and insert mode. Then we have selection modes. The simplest selection mode is V. By pressing V, we are now starting to select different files, different text. So I pressed V and now I'm moving and I'm basically just increasing the selection kind of like how you would do with a mouse. So if I have selected a few lines and now for example I want to delete them. I'll just press D

[\[01:52\]](https://www.youtube.com/watch?v=C_Pe9xlR-WY&t=112s) And I've removed all the offending text. I'm going to press U to undo that. Note that this does not select the whole line just selects whatever I have currently selected and onwards. And I can of course select using B and W as well using special movement. So www to select one more word, BBB to select backwards, E to select the end of the next word, etc., etc. So the navigation keys

[\[02:23\]](https://www.youtube.com/watch?v=C_Pe9xlR-WY&t=143s) Also apply when you're selecting things to increase or decrease the selection. I can then press, for example, C to change the current selection into something else and then press escape, of course, cuz I move from selection mode directly into insert mode by pressing C. I'm going to undo that again. The second selection mode is line selection mode or visual line. And you go into it not by pressing V, but by pressing shift V. So if I press shift V, it doesn't matter if I'm the middle of the line, the whole line is selected.

[\[02:57\]](https://www.youtube.com/watch?v=C_Pe9xlR-WY&t=177s) And now I can move up or down to select or deselect different lines. So I have three lines selected. I can press C and change these lines into something else. I'm going to undo. Shift V. Let's delete these four lines. And now I can undo that, too. And I never actually go into insert mode unless I press C or I. In this case, I didn't even select anything. I just press shift C, which is a different shortcut that I'm going to show in a different video.

[\[03:29\]](https://www.youtube.com/watch?v=C_Pe9xlR-WY&t=209s) One of the coolest selection modes is [block selection](https://www.youtube.com/watch?v=aaCGJCJPSjA "Vimming - Natural Selection (YouTube)") mode. So, you go into it not by pressing V, not shift V, but by pressing Ctrl +V. So, if I press Ctrl +V here, Ctrl +V, now I can select columns and I can expand the selection. And of course I can change the selection just like by changing here. So I pressed C and now I'm going to type a word and I'm going to press escape or space and then I'm going to press escape.

[\[04:03\]](https://www.youtube.com/watch?v=C_Pe9xlR-WY&t=243s) And what you'll see here that all of the bottom lines also got changed into a word. Let me undo that and show again. I'm going to press Ctrl +V select all the is I'm going to press C to change it. I'm going to say was and escape is going to change all the columns to the word was. I can do for example I'm going to go to the beginning by pressing zero. I'm going to select the whole column here. I'm going going to press shift I to insert something right before this.

[\[04:37\]](https://www.youtube.com/watch?v=C_Pe9xlR-WY&t=277s) So I'm going to press star space. I'm going to press escape. And this gets applied to all the columns. So I'm going to press undo here for you. So column selection mode is really, really cool and it can really save you a lot of time. I've seen people do demos where they were kind of selecting things like this. I'm in block selection mode. I'm going to select everything here and then I can press the R to replace my current selection. So R and I'm going to press it with space.

[\[05:08\]](https://www.youtube.com/watch?v=C_Pe9xlR-WY&t=308s) And immediately everything gets changed into space. Let's do another vis block selection. And I'm going to press Ctrl +V and all these spaces I'm going to press R and replace them with and signs. So it's a very powerful the visual block selection mode is very powerful. So we have the three selection modes which is just visual with V, shift V which is full full line selection and controlV

[\[05:39\]](https://www.youtube.com/watch?v=C_Pe9xlR-WY&t=339s) For column selection mode. And then we have insert mode to actually typing. And then we have just movement mode, which is normal mode. So every time you press escape, you go back into normal mode. That's the default. By pressing V or the various V V types, you go into visual selection mode. By pressing I or C or different movements, you go you can go into different insert modes. So that should be enough to get you going and being very productive very very quickly.

## Related

- [Vimming - Natural Selection](https://www.youtube.com/watch?v=aaCGJCJPSjA) · YouTube

    Roy's Vimming episode on visual-mode selections, the character, line and block selection modes this lesson demonstrates.

- [\[Video\] Vimming - All about change](https://osherove.com/blog/2012/5/8/video-vimming-all-about-change.html) · osherove.com

    A Vimming episode on the change command, which the lesson applies to a block selection with c.

[Previous lesson Indentation](https://courses.osherove.com/courses/vim-hates-you/indentation/) [Next lesson Color Schemes](https://courses.osherove.com/courses/vim-hates-you/color-schemes/)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
