How to add spaces to an entire block of lines in Vi

Working with files in Linux can be a pain, especially when you want to add spaces (yaml files) or multiple spaces to large block of text (certificates). This post shows you how to do just that.

Working with files in Linux can be a pain, especially when you want to add spaces (yaml files) or multiple spaces to large block of text (certificates). This post shows you how to do just that.

The below can be used to add spaces into yaml files very easily. Very useful when adding spaces to tls.crt files for example.

  1. Run this command to add line numbers

:set number

  1. Add four spaces from line 8 to line 37, note that between the last / and the preceding / there are four spaces
    :3,37s/^/ /
Advertisement

Author: Hugo Phan

@hugophan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: