Bookmark this page

Guided Exercise: Editing Text Files from the Shell Prompt

In this exercise, you will use vimtutor to practice basic editing techniques in the vim editor.

Outcomes

You should be able to:

  • Edit files using Vim.

  • Gain competency in Vim using vimtutor.

Log in to workstation as student using student as the password.

On workstation, run the lab edit-vim start command. This script verifies that the target server is running.

[student@workstation ~]$ lab edit-vim start
  1. Use the ssh command to log in to servera.

    [student@workstation ~]$ ssh student@servera
    ...output omitted...
    [student@servera ~]$ 
  2. Open vimtutor. Read the Welcome screen and perform Lesson 1.1.

    [student@servera ~]$ vimtutor

    In the presentation, keyboard arrow keys are used for navigation. When vi was first developed, users could not rely on having arrow keys or working keyboard mappings for arrow keys to move the cursor. Therefore, vi was originally designed to move the cursor using commands using 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.

  3. In the vimtutor window, perform Lesson 1.2.

    This lesson teaches users how to quit without keeping unwanted changes. All changes are lost. Sometimes this is preferable to leaving a critical file in an incorrect state.

  4. In the vimtutor window, perform Lesson 1.3.

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

  5. In the vimtutor window, perform Lesson 1.4.

    For most editing tasks, the first key pressed is i.

  6. In 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 other available keystrokes to change the cursor placement when insert mode is entered. In insert mode, all typed text is file content.

  7. In the vimtutor window, perform Lesson 1.6.

    Type :wq to save the file and quit the editor.

  8. In the vimtutor window, read the Lesson 1 Summary.

    The vimtutor command includes six more multistep lessons. These lessons are not assigned as part of this course but feel free to explore them on your own to learn more.

  9. Exit from servera.

    [student@servera ~]$ exit
    logout
    Connection to servera closed.
    [student@workstation ~]$ 

Finish

On workstation, run the lab edit-vim finish script to complete this exercise.

[student@workstation ~]$ lab edit-vim finish

This concludes the guided exercise.

Revision: rh124-8.2-df5a585