It happens more often than not that I have to comment several lines at once in vim. Methods that I know are not as fast as say TextMate way to comment lines out.
What is your favorite way to do it?
I currently use
Method 1:
- go to first char of a line and use blockwise visual mode (CTRL-V)
- go down/up until first char of all lines I want to comment out are selected
- use SHIFT-I and then type my comment character (# for ruby)
- use ESC to insert the comment character for all lines
Method 2:
- Select lines I need to comment out using linewise visual mode (V)
- typing : gives me :'<,'> promt which I extend to :'<,'>s/^/#/
Method 3:
- go to the first line to be commented out
- make a bookmark for example typing mm
- go to the last line to be commented out
- type :'m,.s/^/#/
I like method 1 the most, but I still hope there is a better way.