Bookmark this page

Guided Exercise: Editing Files with Vim

In this lab, you will use a locally installed resource to practice entry-level vim editor techniques.

Outcomes

Experience with vim, and knowledge about using vimtutor to gain competency.

In this exercise, use the existing Vim tutorial bundled with the Vim editor. The installed vim-enhanced package provides vimtutor. For each exercise step, use the corresponding lesson in vimtutor to practice. Return here when the lesson step is complete. Perform the following steps on serverX unless directed otherwise.

  1. Open vimtutor. Read the Welcome screen and perform Lesson 1.1.

    [student@serverX ~]$ vimtutor

    In the lecture, only keyboard arrow keys were used for navigation. In vi's early years, users could not rely on working keyboard mappings for arrow keys. Therefore, vi was designed with commands using only standard character keys, such as the conveniently grouped h, j, k, and l. Here is one way to remember them:

    hang back, jump down, kick up, leap forward.

  2. Return to the vimtutor window. Perform Lesson 1.2.

    This early lesson teaches how to quit without having to keep an unwanted file change. All changes are lost, but this is better than leaving a critical file in an incorrect state.

  3. Return to the vimtutor window. Perform Lesson 1.3.

    Vim has faster, more efficient keystrokes to delete an exact amount of words, lines, sentences, and paragraphs. However, any editing job can be accomplished using only x for single-character deletion.

  4. Return to the vimtutor window. Perform Lesson 1.4.

    The minimum required keystrokes are for entering and leaving edit mode, arrow keys, and deleting. For most edit tasks, the first key pressed is i.

  5. (Optional) Return to the vimtutor window. Perform Lesson 1.5.

    In the lecture, only the i (insert) command was taught as the keystroke to enter edit mode. This vimtutor lesson demonstrates that other keystrokes are available to change the cursor placement when insert mode is entered. However, once in insert mode, all text typed is still file content.

  6. Return to the vimtutor window. Perform Lesson 1.6.

    Save the file by writing and quitting. This is the last lesson for the minimum required keystrokes to be able to accomplish any editing task.

  7. Return to the vimtutor window. Finish by reading the Lesson 1 Summary.

    There are six more multi-step lessons in vimtutor. None are assigned as further lessons for this course, but feel free to use vimtutor on your own to learn more about Vim.

Revision: rh124-7-1b00421