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

Navigating and Changing Directories

If you’ve used Vim a lot, you may have accidentally discovered that you can view a directory and move through it using keystrokes similar to those used with files.

Let’s consider a directory containing many .c files, ex-050325 (this happens to be the directory containing the compilable source for the original vi editor). Edit ex-050325 with:

$vim ex-050325

Figure 15-3 is a partial screenshot of something similar to what you might see.

Vim “editing” the ex-050325 directory
Figure 15-3. Vim “editing” the ex-050325 directory

Vim displays three types of information: introductory comments (preceded by equals signs), directories (displayed with trailing slashes), and files. Each directory or file is on its own line.

There are many ways to use this feature, but with little effort you can be immediately and intuitively productive with standard Vim motion commands (e.g., w to move to the next word, j or the down arrow to jump down one line) and by clicking the mouse over entries. Some particular features of directory mode include:

  • When the cursor is positioned over a directory name, move to that directory by pressing the ENTER key.

  • If the cursor is over a filename, pressing ENTER edits that file.

Tip

If you want to keep the directory window around for further work in that directory, edit the file under the cursor by typing o, and Vim will split the window, editing the file in the newly created window. ...

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