Project

General

Profile

Feature #664

Using Vi to Comment Out a Range of Code

Added by Daniel Curtis about 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Source Code Management
Target version:
Start date:
09/30/2015
Due date:
% Done:

100%

Estimated time:
0.10 h
Spent time:

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

#1

Updated by Daniel Curtis about 9 years ago

  • Description updated (diff)
  • Status changed from New to Resolved
  • % Done changed from 0 to 100
#2

Updated by Daniel Curtis about 9 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF