Using Vi to Comment Out a Range of Code
This is a simple guide on using vi to insert a comment character in front of every line of a given range of line in a text file. I find this extremely useful for testing various blocks of code or configuration files.
- Open a file file with vi:
- Show line numbers in vi:
- To add a # character in front of lines 34-65:
- To remove the # character from the beginning of lines 78-102: