← All lessons

19. The Global Command

Step 3 of 10

Useful Ex commands to use with the global command

Printing with the :print/:p command is the default action for the global command. If you don’t specify an Ex command, it’s assumed that you mean :print.

We can do a lot more than just print, though. Here are some useful Ex commands that you can use in conjunction with :global:

… plus many more.

Any Ex command can be used in conjunction with the global command, so feel free to use your imagination. In my experience, though, the ones listed above are the most useful.

Let’s try this in the editor. Use the global command to delete all of the lines matching foo with :g/foo/d.

Loading editor…