There are a few things you can do to improve the clarity and readability of your configuration file. One is to comment out lines that you don’t need to use, and another is to uncomment lines that you do need to use. Commenting Out Lines To comment out a line in your configuration file, use the following command: #comment-out line Uncommenting Lines To uncomment a line in your configuration file, use the following command: #uncomment line
You may have seen instructions that tell you to “uncomment” or “comment out” lines in a configuration or source code file. This is a simple process, but may not be self-explanatory to people that don’t understand the file’s structure.
The interpreter ignores lines marked as comments, which are only to aid humans in understanding the file. Because of this, comments can be used to disable or enable configuration options in configuration files.
The Short Answer
You can “uncomment a line” in a configuration file by removing the # at the start of the line. Or, to “comment out” a line, add a # character to the start of the line. (Note that some languages have different comment formats, so this may not be true if you’re working with a source code file.)
For example, let’s say you have a file with the following text:
To uncomment the line, you’d remove the # character before it such that the text became:
#FeatureX = Enabled
To comment out a line, you’d follow this process in reverse. For example, this text:
FeatureX = Enabled
Would become:
FeatureY = Enabled
Save the configuration file after making these changes.
#FeatureY = Enabled
What is a Comment?
To understand what exactly this means and why we’re referring to “uncommenting” or “commenting out” lines rather than “enabling” or “disabling” them, it’s important to understand the structure of a configuration file. In addition to actual configuration directives, these files can contain comments. These comments aren’t for the computer – they exist to explain the format of the configuration file to anyone reading it. The # before each line tells the computer that this is a comment line – the computer should ignore it, skip over it, and try to interpret the next line that doesn’t begin with a #.
In some cases, a configuration file may include a configuration option that’s disabled by default. To disable the configuration instruction, a # is included before its line as well, instructing the computer to ignore the line. To enable one of these configuration instructions, all you have to do is remove the # character. To disable any configuration instruction – or add your own comments – just include a # at the start of each line.
Other Comment Formats
While this is the format commonly used in configuration files and shell scripts – most notably on Linux and other UNIX-like operating systems – other languages may use other comment formats.
For example, if you’re working with a PHP script, you might see a section like the one below:
To uncomment the section and enable the feature, you’d change this section to:
to enable feature X, uncomment the section below
line of php code
another line of php code */
This is a multi-line PHP comment (C-style comment) where /* begins the comment and */ ends the comment.
to enable feature X, uncomment the section below */
line of php code
another line of php code