Home > Articles > Operating Systems, Server > Microsoft Servers

  • Print
  • + Share This
From the author of

From the author of

Other Editing Commands

Now that you have gone through a few simple commands, it is time to move on to some slightly more complex operations.

Inserting Characters at the End of a Line

The i command inserts a character before the character under the cursor. That works fine; but what happens if you want to add stuff to the end of the line? For that you need to insert text after the cursor. This is done with the a (append) command.

For example, to change the line

and that's not saying much for the turtle.


and that's not saying much for the turtle!!!

move the cursor over to the dot at the end of the line. Then type x to delete the period. The cursor is now positioned at the end of the line on the e in turtle:

and that's not saying much for the turtle

Now type a!!!<Esc> to append three exclamation points after the e in turtle:

and that's not saying much for the turtle!!!

Deleting a Line

To delete a line, use the dd command, which deletes the line on which the cursor is positioned. To delete the middle line of this example, for instance, position the cursor anywhere on the line. See Figure 6.

Figure 6 Screen before dd command.

Now type dd. Figure 7 shows the results.

Figure 7 Screen after dd command.

Opening Up New Lines

To add a new line, use the o command to open up a new line below the cursor. The editor is then placed in insert mode.

Suppose, for example, that you want to add a line to the sample text just below the third line. Start by leaving the cursor on the Ran as slow. . . line, as seen in Figure 7.

Now type o to open up a new line. Enter the text for the line and then press <Esc> to end insert mode. Figure 8 shows the results.

Figure 8 Screen after using the o command.

If you want to open a line above the cursor, use the O (uppercase) command.


Finally, there's one more important command, the help command. To get help, enter the following:


(Remember the implied <Enter> for command-mode commands.) This displays a general help window, as seen in Figure 9.

Figure 9 Help screen

If you don't supply a subject, :help displays the general help window. The creators of Vim did something very clever (or very lazy) with the help system. They made the help window a normal editing window. You can use all the normal Vim commands to move through the help information. Therefore h, k, j, and l move left, up, down, right, and so on.

To get out of the help system, use the same command you use to get out of the editor: ZZ.

As you read the help text, you will notice some text enclosed in vertical bars (for example, |:help|). This indicates a hyperlink. If you position the cursor anywhere between the bars and press CTRL+] (jump to tag), the help system takes you to the indicated subject. (For reasons not discussed here, the Vim terminology for a hyperlink is tag. So CTRL+] jumps to the location of the tag given by the word under the cursor.)

After a few jumps, you might want to go back. Ctrl+T (pop tag) takes you back to the preceding screen. Or in Vim terms, it "pops a tag off the tag stack."

At the top of this screen, there is the notation *help.txt*. This is used by the help system to define a tag (hyperlink destination).

To get help on a given subject, use the following command:

:help subject

To get help on the x command, for example, enter the following:

:help x

To find out how to delete text, use this command:

:help deleting

To get a complete index of what is available, use the following command:

:help index

When you need to get help for a control character command (for example, CTRL-A, you need to spell it with the prefix CTRL-.

:help CTRL-A

The Vim editor has many different modes. By default, the help system displays the normal-mode commands. For example, the following command displays help for the normal-mode CTRL-H command:

:help CTRL-H

To identify other modes, use a mode prefix.

If you want the help for the insert-mode version of this command, prefix the key with i_. This gives you the following command:

:help i_CTRL-H

Table 1 lists several other mode prefixes.

When you start the Vim editor, you can use several command-line options. These all begin with a dash (-). To find what the -t command-line option does, for example, use the command

:help -t

The Vim editor has a number of options that enable you to configure and customize the editor. If you want help for an option, you need to enclose it in single quotation marks. To find out what the number option does, for example, use the following command:

:help 'number'

The following table summarizes the special prefixes.

Table 1. Help Prefixes




Normal-mode commands


:help x

Control character


:help CTRL-u

Visual-mode commands


:help v_u

Insert-mode commands


:help i_<Esc>

ex-mode commands


:help :quit

Command-line editing


:help c_<Del>

Vim command arguments


:help -r


' (both ends)

:help 'textwidth'

Special keys are enclosed in angle brackets. To find help on the up-arrow key, for instance, use this command:

:help <Up>

Other Ways to Get Help

You can get to the help screen by pressing the <F1> key. This displays the general help screen, and you can navigate from there. If your keyboard has a <Help> key, you can use it as well.

  • + Share This
  • 🔖 Save To Your Account