Answers to: How do you comment out several lines in vi at once?http://linuxexchange.org/questions/337/how-do-you-comment-out-several-lines-in-vi-at-once<p>Lets say I have a block of text:</p> <pre><code>def blarg_func: blarg = 1 return blarg </code></pre> <p>and I want to comment it all out in vi</p> <pre><code>#def blarg_func: # blarg = 1 # return blarg </code></pre> <p>What I usually do is go to the first line and hit "^i" and then enter "#". next I arrow down to the next line and hit "." and then repeat until all the lines are commented. </p> <p>If I hit "2" then "." it will give me.</p> <pre><code>#def blarg_func: ## blarg = 1 return blarg </code></pre> <p>I know I can do this with numbered lines, like </p> <pre><code>:1,3s/^/#/ </code></pre> <p>but I want to be able to do this without having to enter line numbers.</p> <p>Keep in mind I am using vi not vim, so "^v" will not work. </p>enWed, 16 Jul 2014 11:44:43 -0400Answer by Mike Renohttp://linuxexchange.org/questions/337/how-do-you-comment-out-several-lines-in-vi-at-once/3372<p>Remember VI uses sed and awk commands.<br> </p> <p>Research how to do what you want to do with sek and awk commands and you will be way ahead of a VI expert. Visit ora.com to get the best technical books for linux users. O'Reilly permits you purchase directly from them and will sell you the next revision of the book at a discount.</p>Mike RenoWed, 16 Jul 2014 11:44:43 -0400http://linuxexchange.org/questions/337/how-do-you-comment-out-several-lines-in-vi-at-once/3372Answer by Anilhttp://linuxexchange.org/questions/337/how-do-you-comment-out-several-lines-in-vi-at-once/3358<p>For me with MAC running UBUNTU/Centos VMs only working options are vim, crtl+v, crtl+i,shift+i,#,esc </p>AnilMon, 16 Jun 2014 16:33:22 -0400http://linuxexchange.org/questions/337/how-do-you-comment-out-several-lines-in-vi-at-once/3358