Editors (Vim)
MIT 6.NULL The Missing Semester of Your CS Education, lecture 3, explained in plain English
Want this lecture to stick? In LessonBound you get checked practice questions for every part, can ask about anything you don't get, and can listen with your screen off. Free, no ads.
Learn this lecture freeWatch or read the original lecture: MIT OpenCourseWare.
Part 1
This part introduces Vim, a text editor built for programmers, and explains its main ideas and basic controls.
Key ideas
- Programmers spend most of their time reading and editing code, not writing long streams of text. So it pays to learn an editor that fits that work.
- Learning Vim takes time. After about 20 hours you should be as fast as with your old editor, and the time saved after that is what makes it worth it.
- Vim is a modal editor, which means it has different modes. Normal mode is for moving and changing text, and Insert mode is for typing text. The same key does different things in each mode.
- In Normal mode, pressing x deletes the character under the cursor. In Insert mode, pressing x just types the letter x. Press Escape to get back to Normal mode.
- Vim's commands work like small sentences. An action (a verb such as d for delete) combines with a movement (a noun such as w for word), so dw means delete a word.
Words to know
- modal editor
- A text editor that works in different modes. The same key can do different jobs depending on which mode you are in.
- buffer
- A file that Vim has open. Vim keeps a set of these open at once, and a window is just a view of one.
- Insert mode
- The mode where you type text normally, like in any everyday word processor, until you press Escape.
- verb
- In Vim, an action word such as d (delete) or c (change). It acts on a noun, which is a movement that picks out a piece of text.
Example
Think of Vim commands like short instructions to a helper. Saying 'delete word' is quicker than pointing and dragging with a mouse, and 'delete' plus 'word' can be mixed with other words, like 'delete 3 words'. Vim's keys work the same way: d plus w gives dw, and adding a 3 makes 3dw.
3 checked practice questions for this part are in the app.
Part 2
This part shows how to make Vim your own with a config file, add-ons, Vim-style keys in other tools, and macros that repeat edits for you.
Key ideas
- Vim is customized with a plain text file called ~/.vimrc. The file holds Vimscript commands that set how Vim behaves.
- You can add plugins, which are extra features that others have written. Since Vim 8.0 you do not need a plugin manager. You just put the plugin in the built-in folder ~/.vim/pack/vendor/start/.
- Many other programs can use Vim-style keys. For example, Bash users can run set -o vi, and Zsh users can run bindkey -v.
- A macro records a set of key presses so you can replay them later. This lets you repeat a multi-step edit with very few keystrokes.
Words to know
- plugin
- An add-on that gives a program extra features. Someone else usually writes it, and you add it to your program.
- macro
- A saved list of key presses that you can replay with one command, so you do not have to repeat the same steps by hand.
- readline
- A shared piece of code that many command-line programs use to handle typing at the prompt. It can also be set to use Vim-style keys.
- Vimscript
- The simple command language that Vim uses for its settings and configuration.
Example
Think of a macro like a recipe you write down once. If you need to make the same sandwich ten times, you follow the written steps each time instead of working out every move again. Vim records your key presses the same way and plays them back whenever you ask.
3 checked practice questions for this part are in the app.
← Lecture 2: Shell Tools and Scripting · Lecture 4: Data Wrangling →
Notes written by AI (Claude) from the lecture's official transcript, so check anything important against the lecture. MIT CSAIL · CC BY-NC-SA 4.0 · not affiliated with or endorsed by MIT. These notes are shared under the same license.
LessonBound · Free lecture notes · Privacy · Terms · New York