Visual block mode is a great tool when commenting out a section of code, large or small, all at once.
Look at this section of code from a script I am writing. Let’s say I wanted to comment out everything you see.

I start with my cursor on the “%” and enter visual block mode by typing {CTRL}-v , then move the cursor down to the last line I want to comment out.

Then type “I” to insert in front of the slected text (“i” would insert after, and that’s not what we want) and then the “#” character to comment the first lineout.

Once you have the first line commented it’s time for the magic. Hit ESC to let Vim know you are done editing, and it will apply your edit to all the selected lines!

This is a HUGE time saver!




gr8 tip…saved a lot of time! Thanks
Alexy,
YES, vim can do what you are asking. Do what I show in the above example but when you get to the last line, before you hit “esc”, hit “$” to select the end of all lines.
Thanks for posting your question.
Jeff
Jeff
how to select multiple lines (full length) in vim in visual mode when last line is shorter than others?
looks like by default vim using block selection (wrap selection is disabled)
Thanks
Alex.