This post is older than a year. Consider some information might not be accurate anymore.
If you have the need to comment a whole file sed is very handy to comment and uncomment files.
sed -i 's/^\([^#]\)/#\1/g' /etc/monit/elasticsearch
To uncomment remove all # at the beginning of each line.
sed -i 's/^#//g' /etc/monit/elasticsearch