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/^/ /