Skip to Content
Learning the vi and Vim Editors, 7th Edition
book

Learning the vi and Vim Editors, 7th Edition

by Arnold Robbins, Elbert Hannah, Linda Lamb
July 2008
Beginner
492 pages
16h
English
O'Reilly Media, Inc.
Content preview from Learning the vi and Vim Editors, 7th Edition

New Motion Commands

Vim provides all vi movement or motion commands, most of which are listed in Chapter 3, and adds several others, summarized in Table 10-1.

Table 10-1. Motion commands in Vim
CommandDescription
<C-End>Go to the end of the file, i.e., the last character of the last line of the file. If a count is given, go to the last character of the line count.
<C-Home>Go to the first nonwhitespace character of the first line of the file. This differs from <C-End> because <C-Home> does not move the cursor to whitespace.
count %

Go to the line count percent into the file, putting the cursor on the first nonblank line. It’s important to note that Vim bases its calculation on the number of lines in the file, not the total character count. This may not seem important, but consider an example of a file containing 200 lines, of which the first 195 contain 5 characters (for example, prices such as $4.98), and the last four lines contain 1,000 characters. In Unix, accounting for the newline character, the file would contain approximately:

(195 * (5 + 1)) (The number of characters in the first 5-character lines)

+ 2 + (4 * (1000 + 1)) (The number of characters in the 1,000-character lines)

or 5,200 characters. A true 50% count would place the cursor on line 96, and Vim’s 50% motion command would place the cursor on line 100.

:go n

n go

Go to the nth byte in the buffer. All characters, including end-of-line characters, are counted.

Visual Mode Motion

Vim lets users define selections visually ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning the vi and Vim Editors, 8th Edition

Learning the vi and Vim Editors, 8th Edition

Arnold Robbins, Elbert Hannah
Vim Masterclass

Vim Masterclass

Jason Cannon
Mastering Vim

Mastering Vim

Ruslan Osipov

Publisher Resources

ISBN: 9780596529833Errata Page