Chapter 2. Simple Editing

This chapter introduces you to editing with vi and Vim, and it is set up to be read as a tutorial. In it you will learn how to move the cursor and how to make some simple edits. If you’ve never worked with these editors, you should read the entire chapter.

Later chapters show you how to expand your skills to perform faster and more powerful edits. One of the biggest advantages for an adept user is that there are so many options to choose from. Of course, as with many advanced tools, one of the biggest disadvantages for the newcomer to vi and Vim is that there are so many different editor commands to learn.

You can’t learn to use the editor by memorizing every single vi command. Start out by learning the basic commands introduced in this chapter. Note the patterns of use that the commands have in common. We point out these patterns as we encounter them.

As you learn, be on the lookout for more tasks that you can delegate to the editor, and then find the command that accomplishes it. In later chapters you will learn more advanced features of vi and Vim, but before you can handle the advanced, you must master the simple.

This chapter covers:

  • Moving the cursor

  • Simple edits: Adding, changing, deleting, moving, and copying text

  • More ways to enter insert mode

  • Joining lines

  • Mode indicators

vi Commands

As we’ve seen, vi and Vim have two primary modes: command mode and insert mode. The command line (or colon prompt), where you issue ex commands, can ...

Get Learning the vi and Vim Editors, 8th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.