If you’ve ever needed to jump quickly to the next commented line of code, there’s a trick for that. You’ll need to add a new commands to Vim, but that’s as easy as adding a few lines to your .vimrc file. The following maps ]c to jump to the next commented line of code and [c to the previous.

By using &cms (CoMment String) we can make this language agnostic, and it should work in any file recognized.

nnoremap ]c :call search('^\s*'.substitute(escape(&cms, '\.*[]^$'), '%s', '.*', '').'\s*$')<CR>
nnoremap [c :call search('^\s*'.substitute(escape(&cms, '\.*[]^$'), '%s', '.*', '').'\s*$', 'b')<CR>

Now inside a file such as this Ruby file, you can jump to the next commented line by simply tapping ] and c in succession:

def foo

def bar(arg)
  puts "bar:"
  # something important
  puts arg

Special thanks to Tim Pope for crafting this tip and to Andrew Libby for help configuring the mapping.