Comment Ruby code with Vim
I’ve recently started using Vim for Ruby/Rails development. As someone who is very new to Vim it has been a steep learning curve, but I’m really enjoying it – it has definitely become my editor of choice. One of the useful little tricks I figured out today is how to comment out a block of Ruby code.
Here’s what to do.
- Navigate to the beginning of the first line you want to comment
- Press Ctrl + v
- Select the lines you want to comment with j and k
- Press Shift + i
- Press #
- Press Esc
Voila! If you want to do the opposite follow steps 1 to 3 and then simply press d.
This is really just multi-line editing. Happy coding.