Home > Articles

Basic vi Skills

  • Print
  • + Share This
This chapter is from the book

Opening a File for Editing

To create a new file in the current subdirectory, you type the following:

vi filename

To create a new file in a particular directory, use the full path as follows:

vi /full/path/to/file

Sometimes you will want vi to open a file with a search string and put the cursor on the first found instance of that string. To accomplish this you'd enter

vi +/string filename

Other times you'll want to edit a file and have the cursor jump to a particular line when the file is opened, such as the initdefault line in the /etc/ inittab. You'd enter this:

vi +18 /etc/inittab

CAUTION

Expect questions about opening files with particular options, searching a file upon opening it, and other ways to start the vi editor.

  • + Share This
  • 🔖 Save To Your Account