Feature #664
Using Vi to Comment Out a Range of Code
Status:
Closed
Priority:
Normal
Assignee:
Category:
Source Code Management
Target version:
Description
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:
vi /home/user/sometext.conf
- Show line numbers in vi:
:set number
- To add a # character in front of lines 34-65:
:34,65s/^/#
- To remove the # character from the beginning of lines 78-102:
:78,102s/^#/
Resources¶
Updated by Daniel Curtis about 9 years ago
- Description updated (diff)
- Status changed from New to Resolved
- % Done changed from 0 to 100