Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

vi intro -- the cheat sheet method

Daniel Robbins (drobbins@gentoo.org), President/CEO, Gentoo Technologies, Inc.
Daniel Robbins resides in Albuquerque, New Mexico. He is the President/CEO of Gentoo Technologies, Inc., the Chief Architect of the Gentoo Project and a contributing author of several books published by MacMillan: Caldera OpenLinux Unleashed, SuSE Linux Unleashed, and Samba Unleashed. Daniel has been involved with computers in some fashion since the second grade, when he was first exposed to the Logo programming language as well as a potentially dangerous dose of Pac Man. This probably explains why he has since served as a Lead Graphic Artist at SONY Electronic Publishing/Psygnosis. Daniel enjoys spending time with his wife, Mary, and his new baby daughter, Hadassah. You can contact him at drobbins@gentoo.org.

Summary:  This tutorial shows how to use vi, a powerful visual editor. Using an accelerated cheat sheet method, this tutorial aims to make you a proficient vi user without requiring a huge time commitment. You will quickly learn how to move around, edit text, use insert mode, copy and paste text, and use important vim extensions like visual mode and multi-window editing.

Date:  15 Nov 2006 (Published 19 Dec 2000)
Level:  Introductory PDF:  A4 and Letter (234 KB | 13 pages)Get Adobe® Reader®

Activity:  25679 views
Comments:  

Before you start

About this tutorial

The vi editor is the de-facto UNIX® and Linux® text editor. It exists on almost all systems and is available for Windows®, DOS, Macintosh, OS/2, SGI, and many other platforms. If you don't already know vi or aren't comfortable using it, then you owe it to yourself to take this tutorial and get up to speed with one of the most popular and powerful Linux/UNIX visual editing programs.

Objectives

The main objective is to help you learn vi quickly. One thing makes it difficult to learn vi -- vi has lots of commands. To use vi effectively, you need to memorize quite a few. This can take a long time, and one of the goals of this tutorial is not to take up a lot of your time. So, initially, I have a challenge -- how exactly can I help you to memorize lots of commands in a short time?

To tackle this challenge, as we proceed through this tutorial, we're going to gradually put together a vi "cheat sheet". This sheet will contain all the important vi commands. After you've completed this tutorial, you'll be able to refer to this cheat sheet if you forget a particular command. Over time, as you memorize commands, you'll gradually become less dependent on the cheat sheet.

Prerequisites

This tutorial has no prerequisites. It uses several techniques to help you learn. First, I'm going to describe how a particular command works, as you'd expect. Then, I'm going to ask you to try to use the command in vi (for practice), and then I'm going to ask you to transcribe the command to the cheat sheet (for later reference). If you want to learn vi quickly, it's important that you perform all these steps. Trying out a command in vi and transcribing the command onto your cheat sheet will help you to memorize the command.

System requirements

There are many versions of vi, and I'm going to show you how to use a version of vi called "vim." vim is very popular and has a number of extensions that make vi a lot nicer (whenever I demonstrate a vim-specific command, I'll make a note of it). To install vim, see Resources at the end of this tutorial for a link to the vim home page. Vim is a text editor that runs in a terminal window or terminal session. Figure 1 shows a screen shot of vim with the XML source for this tutorial opened in a terminal window.


Figure 1. Running vim
Screen shot of vim

In addition to an enhanced command-line vi, vim also comes with a nice GUI editor called gvim. Figure 2 shows a screen shot of gvim with the same XML source that you saw above.


Figure 2. Running gvim
Sreen shot of gvim

If you're a vi newbie, try to get gvim running on your system. Using vi from a GUI can make things a bit easier for beginners.

1 of 7 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=89527
TutorialTitle=vi intro -- the cheat sheet method
publish-date=11152006
author1-email=drobbins@gentoo.org
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers