Watch
1
0
Fork
You've already forked vim-commentary
0
mirror of https://github.com/tpope/vim-commentary.git synced 2026-11-17 02:22:55 +00:00
commentary.vim: comment stuff out
  • Vim Script 100%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2024-10-21 22:05:30 -04:00
.github Add sponsor button 2019-11-12 18:43:05 -05:00
doc Add b:commentary_startofline option 2019-09-28 11:32:15 -04:00
plugin Tweak whitespace logic when nesting a comment 2024-10-21 22:05:30 -04:00
.gitignore commentary.vim 1.0 2011-08-20 02:59:59 -04:00
CONTRIBUTING.markdown README tweaks 2014-03-10 15:02:13 -04:00
README.markdown Mention filetype command in README 2024-01-12 11:49:31 -05:00

commentary.vim

Comment stuff out. Use gcc to comment out a line (takes a count), gc to comment out the target of a motion (for example, gcap to comment out a paragraph), gc in visual mode to comment out the selection, and gc in operator pending mode to target a comment. You can also use it as a command, either with a range like :7,17Commentary, or as part of a :global invocation like with :g/TODO/Commentary. That's it.

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, it weighs in at under 100 lines of code.

Oh, and it uncomments, too. The above maps actually toggle, and gcgc uncomments a set of adjacent commented lines.

Installation

Install using your favorite package manager, or use Vim's built-in package support:

mkdir -p ~/.vim/pack/tpope/start
cd ~/.vim/pack/tpope/start
git clone https://tpope.io/vim/commentary.git
vim -u NONE -c "helptags commentary/doc" -c q

Make sure this line is in your vimrc, if it isn't already:

filetype plugin indent on

FAQ

My favorite file type isn't supported!

Relax! You just have to adjust 'commentstring':

autocmd FileType apache setlocal commentstring=#\ %s

Self-Promotion

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

License

Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. See :help license.