Skip to content
commentary.vim: comment stuff out
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Comment stuff out. Use \\\ to comment out a line (takes a count), \\ to comment out the target of a motion (for example, \\ap to comment out a paragraph), and \\ in visual mode to comment out the selection. That's it.

Install repeat.vim to enable repeating with . the line commenting map \\\.

I wrote this because 5 years after Vim added support for mapping an operator, I still couldn't find a commenting plugin that leveraged that feature (I overlooked tcomment.vim. Striving for minimalism, the first version weighed in at just 35 lines of code.

Oh, and it uncomments, too.


If you don't have a preferred installation method, I recommend installing pathogen.vim, and then simply copy and paste:

cd ~/.vim/bundle
git clone git://

Once help tags have been generated, you can view the manual with :help commentary.


My favorite file type isn't supported!

Relax! You just have to adjust 'commentstring':

autocmd FileType apache set commentstring=#\ %s

What if I want custom maps?

Fly by the seat of your pants and map directly to the \ maps:

xmap gc  \\
nmap gc  \\
nmap gcc \\\


See the contribution guidelines for pathogen.vim.


Like rails.vim? Follow the repository on GitHub and vote for it on And if you're feeling especially charitable, follow tpope on Twitter and GitHub.


Distributable under the same terms as Vim itself. See :help license.

Something went wrong with that request. Please try again.