The NERD Commenter - A plugin that allows for easy commenting of code for many filetypes. : vim online
Keywords: Vim, Vi IMproved, text editor, home, documentation, tips, scripts, news

The NERD Commenter : A plugin that allows for easy commenting of code for many filetypes.
script karma | Rating 2008/681, Downloaded by 65535 | Comments, bugs, improvements | Vim wiki
created by
Marty Grenfell
script type
utility
description
Grab the latest dev version from github: https://github.com/scrooloose/nerdcommenter. The following key mappings are provided by default (there is also a menu provided that contains menu items corresponding to all the below mappings): Most of the following mappings are for normal/visual mode only. The |NERDComInsertComment| mapping is for insert mode only. [count]<leader>cc |NERDComComment| Comment out the current line or text selected in visual mode. [count]<leader>cn |NERDComNestedComment| Same as <leader>cc but forces nesting. [count]<leader>c<space> |NERDComToggleComment| Toggles the comment state of the selected line(s). If the topmost selected line is commented, all selected lines are uncommented and vice versa. [count]<leader>cm |NERDComMinimalComment| Comments the given lines using only one set of multipart delimiters. [count]<leader>ci |NERDComInvertComment| Toggles the comment state of the selected line(s) individually. [count]<leader>cs |NERDComSexyComment| Comments out the selected lines ``sexily'' [count]<leader>cy |NERDComYankComment| Same as <leader>cc except that the commented line(s) are yanked first. <leader>c$ |NERDComEOLComment| Comments the current line from the cursor to the end of line. <leader>cA |NERDComAppendComment| Adds comment delimiters to the end of line and goes into insert mode between them. |NERDComInsertComment| Adds comment delimiters at the current cursor position and inserts between. Disabled by default. <leader>ca |NERDComAltDelim| Switches to the alternative set of delimiters. [count]<leader>cl [count]<leader>cb |NERDComAlignedComment| Same as |NERDComComment| except that the delimiters are aligned down the left side (<leader>cl) or both sides (<leader>cb). [count]<leader>cu |NERDComUncommentLine| Uncomments the selected line(s).
install details
The NERD Commenter requires Vim 7 or higher. Extract the plugin files in your ~/.vim (*nix) or ~/vimfiles (Windows). You should have 2 files: plugin/NERD_commenter.vim doc/NERD_commenter.txt Next, to finish installing the help file run: :helptags ~/.vim/doc See |add-local-help| for more details. Make sure that you have filetype plugins enabled, as the script makes use of |'commentstring'| where possible (which is usually set in a filetype plugin). See |filetype-plugin-on| for details, but basically, stick this in your vimrc filetype plugin on
script versions (upload new version) Click on the package to download.
package | script version | date | Vim version | user | release notes
--- | --- | --- | --- | --- | ---
nerdcommenter.zip | 2.3.0 | 2010-12-07 | 7.0 | Marty Grenfell | - remove all filetypes which have a &commentstring in the standard vim runtime for vim > 7.0 unless the script stores an alternate set of delimiters - make the script complain if the user doesnt have filetype plugins enabled - use <leader> instead of comma to start the default mappings - fix a couple of bugs with sexy comments - thanks to Tim Smart - lots of refactoring
NERD_commenter.zip | 2.2.2 | 2009-03-30 | 7.0 | Marty Grenfell | - remove the NERDShutup option and the message is suppresses, this makes the plugin silently rely on &commentstring for unknown filetypes. - add support for dhcpd, limits, ntp, resolv, rgb, sysctl, udevconf and udevrules. Thanks to Thilo Six. - match filetypes case insensitively - add support for mp (metapost), thanks to Andrey Skvortsov. - add support for htmlcheetah, thanks to Simon Hengel. - add support for javacc, thanks to Matt Tolton. - make <%# %> the default delims for eruby, thanks to tpope. - add support for javascript.jquery, thanks to Ivan Devat. - add support for cucumber and pdf. Fix sass and railslog delims, thanks to tpope
NERD_commenter.zip | 2.2.1 | 2008-11-13 | 7.0 | Marty Grenfell | - add support for newlisp and clojure, thanks to Matthew Lee Hinman. - fix automake comments, thanks to Elias Pipping - make haml comments default to -# with / as the alternative delimiter, thanks to tpope - add support for actionscript and processing thanks to Edwin Benavides - add support for ps1 (powershell), thanks to Jason Mills - add support for hostsaccess, thanks to Thomas Rowe - add support for CVScommit - add support for asciidoc, git and gitrebase. Thanks to Simon Ruderich. - use # for gitcommit comments, thanks to Simon Ruderich. - add support for mako and genshi, thanks to Keitheis. - add support for conkyrc, thanks to David - add support for SVNannotate, thanks to Miguel Jaque Barbero. - add support for sieve, thanks to Stefan Walk - add support for objj, thanks to Adam Thorsen.
NERD_commenter.zip | 2.2.0 | 2008-10-03 | 7.0 | Marty Grenfell | - rewrote the mappings system to be more "standard". - removed all the mapping options. Now, mappings to <plug> mappings are used - see :help NERDComMappings, and :help NERDCreateDefaultMappings for more info - remove "prepend comments" and "right aligned comments". - add support for applescript, calbire, man, SVNcommit, potwiki, txt2tags and SVNinfo. Thanks to nicothakis, timberke, sgronblo, mntnoe, Bernhard Grotz, John O'Shea, François and Giacomo Mariani respectively. - bugfix for haskell delimiters. Thanks to mntnoe.
NERD_commenter.zip | 2.1.18 | 2008-07-27 | 7.0 | Marty Grenfell | - add support for llvm. Thanks to nicothakis. - add support for xquery. Thanks to Phillip Kovalev. - fixed haskell delimiters (hackily). Thanks to Elias Pipping. - add support for mailcap. Thanks to Pascal Brueckner. - add support for stata. Thanks to Jerónimo Carballo. - applied a patch from ewfalor to fix an error in the help file with the NERDMapleader doc - disable the insert mode ctrl-c mapping by default, see :help NERDComInsertComment if you wish to restore it
NERD_commenter.zip | 2.1.16 | 2008-06-26 | 7.0 | Marty Grenfell | compatibility fix for vim7.2, cheers to Ben Schmidt, David Fishburn, and Erik Falor for the emails, and to JaGoTerr for posting the issue.
NERD_commenter.zip | 2.1.15 | 2008-06-21 | 7.0 | Marty Grenfell | - added pamconf support, thanks to Martin Kustermann - added mason support, thanks to Indriği Einarsson - added map support, thanks to Chris - added bzr support, thanks to Stromnov - added group support, thanks to Krzysztof A. Adamski - change license to wtfpl
NERD_commenter.zip | 2.1.14 | 2008-05-16 | 7.0 | Marty Grenfell | - added support for gitconfig, tar, nerdtree - added support for dtrace, thanks to nicothakis for the post
NERD_commenter.zip | 2.1.13 | 2008-05-03 | 7.0 | Marty Grenfell | - added support for rib, pyrex/cython, liquid, services, gitcommit, vimperator, and slice. Thanks to spookypeanut, Greg Jandl, Christophe Benz, A Pontus, and Stromnov for emailing me and/or posting issues. - set the NERDRemoveExtraSpaces option to 1 by default as the doc states - other fixes: (thanks to Zhang Shuhan for all his emails and testing) * made the sexy comment mapping fall back to normal commenting if sexy comments arent possible for the current filetype * fixed some bugs with sexy comments * made the uncommenting side of toggle comments slightly more robust * fixed a bug where some extra spaces werent being removed (although the currect options were set)
NERD_commenter.zip | 2.1.12 | 2008-03-30 | 7.0 | Marty Grenfell | - added support for patran and dakota, thx to Jacobo Diaz for the email - added support for gentoo-env-d, gentoo-init-d, gentoo-make-conf, grub, modconf and sudoers filetypes, thx to Li Jin for the patch. - added support for SVNdiff, gitAnnotate, gitdiff. Thx to nicothakis for posting the issue
NERD_commenter.zip | 2.1.11 | 2008-02-23 | 7.0 | Marty Grenfell | - fixed a bug with the selection option and visual commenting (again). Thanks to Ingo Karkat (again).
NERD_commenter.zip | 2.1.10 | 2008-02-22 | 7.0 | Marty Grenfell | - added support for Wikipedia (thanks to Chen Xing) - added support for mplayerconf - bugfixes (thanks to Ingo Karkat for the bug report/patch) - added support for mkd (thanks to Stefano Zacchiroli)
NERD_commenter.zip | 2.1.9 | 2008-01-18 | 7.0 | Marty Grenfell | - added support for mrxvtrc and aap, thx to Marco for the emails - added dummy support for SVNAnnotate, SVKAnnotate and CVSAnnotate, thx to nicothakis for posting the issue
NERD_commenter.zip | 2.1.8 | 2007-12-13 | 7.0 | Marty Grenfell | - fixed a couple of bugs with the NERDSpaceDelims option, thx to David Miani and Jeremy Hinegardner - added dummy support for lhaskell, thx to pipp for posting the issue - added an alternative set of delims for the plsql filetype, thx to Kuchma Michael - added support for spectre, thx to Brett Warneke - added support for scala, thx to Renald Buter - added support for asymptote, thx to Vladimir Lomov - made NERDDefaultNesting enabled by default as this seems more intuitive, thx to marco for the suggestion
NERD_commenter.vim | 2.1.6 | 2007-10-25 | 7.0 | Marty Grenfell | - added support for gentoo-conf-d thanks to tinoucas for posting the issue and the patch - added support for the D filetype. Thanks to Greg Weber for the email. - added dummy support for cobol, cheers to timberke for posting the issue. - added support for velocity. Thanks to Bruce Sherrod for the email.
NERD_commenter.vim | 2.1.5 | 2007-10-12 | 7.0 | Marty Grenfell | - added support for lilypond, bbx and lytex. Thanks to Eyolf Østrem for the email. - added an alterative set of delimiters for the dosbatch filetype, thanks to Ingo Karkat for the email. - added support for the markdown filetype. Thanks to Nicolas Weber for posting the issue.
NERD_commenter.vim | 2.1.4 | 2007-09-29 | 7.0 | Marty Grenfell | - added support for the ahk filetype. Cheers to Don Hatlestad for the email. - added support for desktop and xsd filetypes. Thanks to Christophe Benz. - added dummy support for Rails-log - fixed a bunch of bugs in the comment delimiter setup process, thanks to Cheng Fang for the email :D - hardcore refactoring and removal of seldomly used, overly-complex functionality - the script now requires vim 7
NERD_commenter.vim | 2.1.3 | 2007-08-27 | 6.0 | Marty Grenfell | - fixed numerous bugs that were causing tabs to permanently be converted to spaces, even if noexpandtab was set. Thanks to Heptite on #vim for working with me to track them down :) - added dummy support for "lookupfile". Thanks to David Fishburn for the email. - added support for "rst", thanks to Niels Aan de Brugh for the email.
NERD_commenter.vim | 2.1.2 | 2007-08-22 | 6.0 | Marty Grenfell | Added support for the vera and ldif filetypes. Thanks to Normandie Azucena and Florian Apolloner for the emails.
NERD_commenter.vim | 2.1.1 | 2007-08-18 | 6.0 | Marty Grenfell | - added dummy support for SVNcommitlog and vcscommit. Thanks to John O'Shea for the email. - added support for Groovy. Thanks to Jason Mills for the email.
NERD_commenter.vim | 2.1.0 | 2007-08-08 | 6.0 | Marty Grenfell | - now the script resets the delimiters when the filetype of the buffer changes (thanks to James Hales for the patch) - added formal support/doc for prepending a count to many of the commenting maps so you can go, eg, 5,cc to comment 5 lines from normal mode. Thanks again to James Hales for the patch. - added support for the "gams" filetype that Jorge Rodrigues created. - added support for the "objc" filetype, thanks to Rainer Müller for the email. - added support for the "sass" filetype that Dmitry Ilyashevich created.
NERD_commenter.vim | 2.0.7 | 2007-07-22 | 6.0 | Marty Grenfell | Added support for eclass and ebuild filetypes. Thanks to Alex Tarkovsky for the email.
NERD_commenter.vim | 2.0.6 | 2007-06-29 | 6.0 | Marty Grenfell | - Changed the default setting of NERDMapleader to ",c", meaning all the maps now start with ,c instead of \c. This is to stop a major mapping clash with the vcscommand plugin. Anyone wanting to keep the \c map leader should read :help NERDMapleader. - Added support for debcontrol and dummy support for debchangelog filetypes, thanks to Stefano Zacchiroli for the email. - Made it so that the NERDShutUp option now only controls the "Pleeease email the delimiters..." requests. It no longer affects the general output of the script. - Simplified the names of the help tags.
NERD_commenter.vim | 2.0.5 | 2007-06-16 | 6.0 | Marty Grenfell | - Added support for autoit, autohotkey and docbk filetypes (thanks to Michael Böhler) - Added support for cmake (thanks to Aaron Small) - Added support for htmldjango and django filetypes (thanks to Ramiro Morales) - Improved the delimiters for eruby again - Applied a patch from Seth Mason to fix some pathing issues with the help file installation.
NERD_commenter.vim | 2.0.4 | 2007-05-11 | 6.0 | Marty Grenfell | - Added support for verilog_systemverilog and systemverilog filetypes (Thanks to Alexey for the email) - Added support for fstab, thanks to Lizendir for the email. - Added support for the smarty filetype. - Improved the delimiters for eruby. - Added dummy support for changelog filetype.
NERD_commenter.vim | 2.0.3 | 2007-05-03 | 6.0 | Marty Grenfell | - Added dummy support for the csv filetype (thx to Mark Woodward for the email) - Added dummy support for vo_base and otl filetypes (thanks to fREW for the email)
NERD_commenter.vim | 2.0.2 | 2007-04-13 | 6.0 | Marty Grenfell | Minor bug fix that was stopping nested comments from working
NERD_commenter.vim | 2.0.1 | 2007-04-12 | 6.0 | Marty Grenfell | - Fixed the visual bell for the |NERDComToEOLMap| map. - Added another possible value to the NERDMenuMode option which causes the menu to be displayed under 'Plugin -> Comment'. See :h NERDMenuMode. This new menu mode is now the default. - Added support for the occam filetype (thanks to Anders for emailing me) - Made the main commenting function (NERDComment) available outside the script. See :h NERD_com_NERDComment - bug fixes and refactoring
NERD_commenter.vim | 2.0.0 | 2007-04-02 | 6.0 | Marty Grenfell | - NOTE: renamed the script to NERD_commenter.vim. When you install this version you must delete the old files: NERD_comments.vim and NERD_comments.txt. - Reworked the mappings and main entry point function for the script to avoid causing visual-bells and screen scrolling. - Changes to the script options (see |NERD_com-Customisation| for details): - They are all camel case now instead of underscored. - Converted all of the regular expression options into simple boolean options for simplicity. - All the options are now stated positively, eg. NERD_dont_remove_spaces_regexp has become NERDRemoveExtraSpaces. - Some of the option names have been changed (other than in the above ways) - Some have been removed altogether, namely: NERD_create_h_filetype (why was a commenting script creating a filetype?!), NERD_left_align_regexp, NERD_right_align_regexp, - Removed all the NERD_use_alt_style_XXX_coms options and replaced them with a better system. Now if a filetype has alternative delims, the script will check whether an option of the form "NERD_<&filetype>_alt_style" exists, and if it does then alt delims will be used. See |NERD_com-cust-delims| for details. - The script no longer removes extra spaces for sexy comments for the NERDRemoveExtraSpaces option (it will still remove spaces if NERDSpaceDelims is set). - Added dummy support for viminfo and rtf. - Added support for the "gentoo-package-\(keywords\|mask\|use\)" filetypes. - Added '#' comments as an alternative for the asm filetype Thanks to Markus Klinik and Anders for bug reports, and again to Anders for his patch. Thanks to John O'Shea and fREW for the filetype information.

| If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly. Questions about Vim should go to the maillist. Help Bram help Uganda. |  |