Having :Sex with Vim (i.e. browsing the filesystem using Vim)

Vim is a huge subject. I wrote a short intro book on that subject, but some of you though it was too short and asked me to write more. Which I did. And here’s one section that will make you smile while you learn a practical Vim trick!

The following Vim lesson is an excerpt from “Vim and Vi Tips.” You can get in PDF in a couple of minutes!

Browsing the Filesystem Inside Vim

You can browse the local filesystem from within vim in two ways: using the text mode browser or the Open and Save As file dialogs. The latter option is only available in the versions of vim that run as stand-alone GUI applications.

Browsing in text mode can be done in three different layouts: standard, vertical, and tabbed.

Each layout presents the list of files in the current working directory. The thin horizontal line indicates the current choice of the file/directory.

The horizontal view is handy if you are working with long file or directory names. You enable it with the :Sex command:

How-To:

  1. Press Esc to switch to command mode.
  2. Type :Sex
  3. Press Enter/Return.

To navigate the filesystem, use the following commands:

  • Move Up — press k.
  • Move Down — press j.
  • Move to a Subdirectory — select the subdirectory and press Enter/Return.
  • Move to a Parent Directory — select the .. directory and press Enter/Return.
  • Open a File — select the file you want to open and press Enter/Return.

Because vim treats the list of the files in a directory as if it was a file, all cursor movement commands can be used.

Did you enjoy this short Vim lesson? There are plenty more practical Vim tips in Vim and Vi Tips! You can get in PDF in a couple of minutes!

Buy Now