sponsor Vim development Vim logo Vim Book Ad

tComment : An extensible & universal comment plugin that also handles embedded filetypes

 script karma  Rating 257/90, Downloaded by 10104    Comments, bugs, improvements  Vim wiki

created by
Tom Link
 
script type
utility
 
description
:TComment works like a toggle, i.e., it will comment out text that
contains uncommented lines, and it will uncomment already
commented text (i.e. text that contains no uncommented lines).

If the file-type is properly defined, :TComment will figure out which
comment string to use based on the values of &commentstring or &comments.
For some filetypes, the comment definition is explicitly defined. You can
|tcomment#DefineType()| to add your own definitions.

TComment knows how to deal with embedded code of a different filetype
than the main filetype, e.g., ruby/python/perl regions in vim scripts, HTML or
JavaScript in php code etc.

As operator (the prefix can be customized via g:tcommentMapLeaderOp1
and g:tcommentMapLeaderOp2):

    gc{motion}   :: Toggle comments (for small comments within one line
                    the &filetype_inline style will be used, if
                    defined)
    gcc          :: Toggle comment for the current line
    gC{motion}   :: Comment region
    gCc          :: Comment the current line

Primary key maps:

    <c-_><c-_>   :: :TComment
    <c-_><space> :: :TComment <QUERY COMMENT-BEGIN ?COMMENT-END>
    <c-_>b       :: :TCommentBlock
    <c-_>a       :: :TCommentAs <QUERY COMMENT TYPE>
    <c-_>n       :: :TCommentAs &filetype <QUERY COUNT>
    <c-_>s       :: :TCommentAs &filetype_<QUERY COMMENT SUBTYPE>
    <c-_>i       :: :TCommentInline
    <c-_>r       :: :TCommentRight
    <c-_>p       :: Comment the current inner paragraph

There is also a secondary set of key maps with <Leader>_ as leader (more
preferable on terminals).

The full documentation is available here:
http://github.com/tomtom/tcomment_vim/blob/master/doc/tcomment.txt

Demo:
http://vimsomnia.blogspot.com/2010/11/tcomment-vim-plugin.html

Also available via git
http://github.com/tomtom/tcomment_vim
 
install details
Edit the vba file and type:

    :so %

See :help vimball for details. If you use vim 7.0, you may need to
update your vimball installation first.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
tcomment.vba 3.03 2014-04-13 7.0 Tom Link - GetStartEnd: ignore empty lines when determining the indentation level
- FIX #96: StartColRx(): Use "^" only for col < 1 (not <= 1)
- FIX #97: Set startcol depending on comment_mode
MD5 checksum: c6a7ac7e915d5cf7a710aa8f118b50de
tcomment.vba 3.02 2014-04-01 7.0 Tom Link - b:tcomment_def_{NAME}: Buffer-local configuration (closes #93)
- FIX #94: if line("'<") == line("'>") and col('.') is before the first character, use G mode
- FIX 95: GetStartEnd(): Don't set cbeg to 0 on empty lines
MD5 checksum: 5bca91c102f1192cccb75708659f825c
tcomment.vba 3.01 2014-03-28 7.0 Tom Link - Support for vimwiki (closes #80)
- Better handling of commentstrings like "%%%s"
- Support for verilog & verilog_systemverilog (closes #81)
- verlog inline comments
- Improved support for constructing comments from the &comments option
- Typo (fixes #82)
- Misc improvements to handling &comment, &commentstring; count for c-style comments only changes the first part of the comment; enable counts for gcb
- Ignore count for xmaps
- Re-enable custom verilog definitions (after debugging)
- Use strdisplaywidth() only with vim >= 7.3 (fixes #83)
- Disallow unsupported comment types (e.g. insert comments when only linewise comments are allowed)
- Remove custom javaScript comment definitions (use javascript)
- Misc changes to operator maps; gc$ maps to R-type comments (fixes #84)
- x/v op map: Use R type comment if cend ~~ col('$') (fixes #85)
- Maps are not <silent> any more (display error/warning message if any)
- If comment_mode == 'i', also check if it should rather be 'G'
- Make op maps silent again
- Improve configurability of mappings.
- Consistently use virtcol(); block comments properly support mixedindent
- Removed some superfluous :exec commands from map definitions
- Fix regression with text objects.
- <c-_>NUMBER maps always set the count argument for the subsequent map (makes it easier to insert /** */ type of comments)
- Misc changes (fixes #88)
- Let g:tcomment_types override default settings
- Support for blade.php (closes #90)
- Support for QML files (Qt Meta Language)
- FIX #92: GuessFileType(): avoid "E706: Variable type mismatch"
MD5 checksum: 10b548c1bfc946206ec46fca58ae5a62
tcomment.vba 3.00 2014-01-17 7.0 Tom Link - Help template
- Add asciidoc (//) and expect (#) definitions
- Fix xs commentstring
- Accept js as alias for javascript (fixes #70)
- Adding hy support
- s:GetStartEnd(): Make sure end >= begin (fixes #73)
- strip_whitespace defaults to 1 (fixes #54)
- "whitespace" option: Consistently use partial matching
- mixedindent option: Check only in s:StartColRx()
- s:CommentDef(): Minor optimization
- Support for remind filetype (closes #74)
- tcomment#TypeExists(name, ...): takes a mode as optional second argument
- R comments: Properly set cend to col('$')
- s:StartPosRx(), s:EndPosRx(): Ignore lnum in I mode
- s:StartColRx(): Takes a col as second argument
- Renamed g:tcommentBlankLines to g:tcomment#blank_lines (can be 0, 1, 2)
- s:GetCustomCommentString(): Take into account whether a custom comment style is defined for block & inline comments
- g:tcomment#rstrip_on_uncomment: Remove right-hand whitespace on uncomment
- Use a loop, not :s
- g:tcomment#ignore_comment_def
- mixedindent option defaults to 1
- mixedindent defaults to 1
MD5 checksum: c2668f9147783d47e640133e51ba20e4
tcomment.vba 2.09 2013-10-18 7.0 Tom Link - Adds Scala support
- Support for (firefox) chromemanifest filetype
- g:tcommentMaps: If true, set maps (fixes #42)
- addon-info
- Enable replacements for xml/html/... (fixes #44)
- Experimental option g:tcomment#mixed_indentation: Deal with inconsistent indentation styles (fixes #43)
- Experimental option 'mixedindent': Deal with inconsistent indentation styles (fixes #43)
- s:DoReplacements(): Handle an empty list of tokens correctly
- mixedindent: Set virtual column to strdisplaywidth(indentStr, cbeg) + 1
- mixedindent: mixedindentUndo previous change; use \%>v again
- Call :redraw only when tcomment#Complete* was called for the first time if v:version < 703
- s:FEscapeCommentString(): Correctly deal comment string that include %
- More flexible handling of "dotted" filetypes (fixes #45)
- Undo previous changes (s:FEscapeCommentString) (fixes #46)
- Map erubyExpression syntax to ruby filetype
- s:StartColRx(pos): Use ^ for pos 0-1 (fixes #47)
- If mixedindent: use col - 1
- Derive g:tcommentLineC from g:tcommentInlineC so that you can set g:tcommentLineC without having to set g:tcommentInlineC
- mixedindent: Adjust column only for inline comments
- g:tcommentModeExtra: Basic support for preferring block-type comments 'B' uncommenting doesn't work properly when called from operator maps
- Support for gcb maps (block comments) and experimental support for '#' mode extra for operator maps (fixes #49)
- opextra =~'#*: Adjust for commentstring containing printf placeholders (%) (closes #49)
- s:GuessFileType(): If there is no custom definition for the fallback filetype, use the filetype (fixes #45)
- g:tcomment#filetype_map now works on filetype parts (when using dotted filetype) & special support for rails-views (fixes #45)
- Support for postfix main (thanks to ypid)
- strip_whitespace option (closes #54)
- Support for cmake.
- Support for markdown.
- Support for sshdconfig.
- Support for sshconfig.
- Support for gnuplot (fixes #56)
- Support slim template
- s:CommentDef(): Uncommenting: correct string for &selection == inclusive (fixes #53)
- Support for esmtprc.
- "whitespace" option: Define whether to surround commented text with whitespace
- Experimental inline comment text object (not functional yet)
- tcomment#DefineType(name, commentdef, ?cdef={}, ?anyway=0)
- s:SetWhitespaceMode(cdef): Add whitespace if mode = "both" and the commentstring doesn't include whitespace
- Support for R6RS scheme block comments (fixes #60)
- Support for upstart.
- Support for racket filetype (fixes #60)
- Added form support
- Adding htmljinja support (same as htmldjango).
- Adding lua support
- Objective C++
- Support for salt stacks (closes #66); sort order of filetypes
- Support for dustjs (closes #67)
MD5 checksum: d507f7e6d171034a45e2d349561d29f1
tcomment.vba 2.08 2012-12-28 7.0 Tom Link - Enable count for gc operator maps (use e.g. 3gc2l instead of gc3c2l; maybe remove gc<count>c maps later on)
- <count>gc operator maps: use v:count instead of v:count1
- fixed unlet
- Merge branch 'master' of https://github.com/grassofhust/tcomment_vim
- Added vhdl to tcomment#DefineType
- tcomment#GuessCommentType(): Make filetype guessing accessible for other plugins
- FIX: didn't guess filetype correctly for lines containing only one character
- Guess filetype: Improved handling of empty lines
- g:tcommentSyntaxMap: support additional info on how to handle empty lines
- g:tcommentSyntaxMap: support filetype key: explicitly map syntax name per filetype (fixes #39)
- Fix typo
- Add `g:tcommentGuessFileType_smarty = 1`
- Define/handle 'ini' file type (e.g. for php.ini)
MD5 checksum: 702082a857ddeaf75d3b4fd884363173
tcomment.vba 2.07 2012-11-23 7.0 Tom Link - Avoid duplicate tag in help file (reported by utkarshkukreti)
- add puppet type
- Use \r instead of ^M
- support for haml and coffeescript
- Support for gitignore
- Merge branch 'master' of https://github.com/ignovak/tcomment_vim
- Enable "filetype guessing" for eruby (fixes #25)
- g:tcommentModeExtra: Always modify how commenting works
- g:tcommentModeExtra: >> ... Like > but also move the cursor to the next line
- adding gnu smalltalk comment style
- Add comment definition for "smarty"
- Sort definition for "sql"
- Merge branch 'master' of https://github.com/clutt0n/tcomment_vim
- added support for jasmine.coffee (cf. https://github.com/claco/jasmine.vim)
- fixed jasmine (have to use syntax instead of filetype)
- Block comments: set &sel = exclusive (fixes #30; bug 1)
- Merge branch 'master' of https://github.com/paulwittmann/tcomment_vim
- spec files for issue 30
- Inline comments: Include the current character if selection == inclusive (fixes #30 bug 2)
- gC in visual mode: call :TCommentMaybeInline! (fixes #30 bug 3)
- Added Clojure and Clojurescript support. Thou the comment is a single ';' it is a widely adopted convention to comment whole lines with ';;'
- command line completion: also offer rx*= arguments
- Merge branch 'master' of https://github.com/ssedano/tcomment_vim
- clojure: use ";" for inline comments
- TCommentRight used wrong column
- b:tcommentOptions: buffer-local options
- Deal with mode argument (concatenate with commentMode)
- Removed visual/selection maps for :TCommentRight
- <c-_>cc and <c-_>ca maps to temporary set options (count, as) on the fly
- <c-_>1 .. <c-_>9 maps to invoke :TComment count=N (repeat the comment string N times)
- clojure: use the "count" property instead of hardcoding the double semicolon (";;")
- Enable inline comments for insert & normal mode (create empty comments, which isn't always that useful; fixes #33)
- When guessing a filetype, make sure to use custom definitions when no syntax name is found
- gc<count>c maps that set the "count" attribute
- Make sure to ignore %%s in commentstrings
- gc<Count>c{motion} maps work as toggle
- Enable <c-_><Count> maps for insert mode
- Monkey language comment style
MD5 checksum: 0853c50ebdcd4c52a31b2ad2d514d1e0
tcomment.vba 2.06 2012-01-21 7.0 Tom Link - tcomment#Comment(): Remove last item in search history (reported by Raimond)
- Add config for conkyrc filetype.
- Add config for 'robots' filetype.
- tcomment#GetCommentDef(name)
- g:tcomment_types: override tcomment's default comment styles (fix #12)
- Fixed ft-guessing of htmldjango files
- Add definitions for dnsmasq, pac, resolv and squid.
- Avoid the problem reported in https://github.com/tomtom/tcomment_vim/pull/18
- Handle nested comments in c mode (fix #19)
MD5 checksum: 0e23f194638256fb4fa4a729df645966
tcomment.vba 2.05 2011-05-26 7.0 Tom Link - Explicit support for python (thanks to brendanarnold)
- Support for samba (thanks Dominic)
- .gitignore
- Define new types: debsources and debcontrol
- Removed some whitespace as proposed by blueyed
- Add config for typoscript filetype.
- EXPERIMENTAL commentstring_rx: Support for using regexps to uncomment code
- s:ProcessedLine: Don't substitute(rv, '\n', '\\\n', 'g')
- Try to handle char-type text objects (disabled by default)
- scss (SASS) filetype
- Add config for 'nginx' filetype.
MD5 checksum: 0e23f194638256fb4fa4a729df645966
tcomment.vba 2.04 2011-01-20 7.0 Tom Link - Support for fstab
- g:tcommentOptions: Other key-value options used by |tcomment#Comment()|.
- Support for django (thanks to Jim Tinsky)
- g:tcomment#syntax_substitute: Rewrite syntax names
- django support: minor correction
MD5 checksum: 994e5886d185857848b5472d5457b232
tcomment.vba 2.03 2010-12-07 7.0 Tom Link - s:PrintF(): Silently ignore malformed format strings
- Deal with major.minor pseudo-filetypes
- go-lang
- Remove s:SPrintF() since vim now has printf()
MD5 checksum: 4a13ffb1b1d46bbd2dc8dcee77507983
tcomment.vba 2.1 2010-10-02 7.0 Tom Link Minor bug fix.
tcomment.vba 2.0 2010-09-14 7.0 Tom Link - Support for erlang (thanks to Zhang Jinzhu)
- Support for x86conf
- Changed comment string for eruby (proposed by Vinicius Baggio)
- NEW: Enabled key=value pairs to configure commenting
- CHANGE: Moved the definition of some variables from plugin/tComment.vim to autoload/tcomment.vim
- CHANGE: Renamed the file plugin/tComment.vim to plugin/tcomment.vim
- CHANGE: Renamed certain global functions to tcomment#...
tComment.vba.gz 1.10 2009-10-11 7.0 Tom Link - tcomment#Operator defines w:tcommentPos if invoked repeatedly
- s:GuessFileType: use len(getline()) instead of col()
tComment.vba.gz 1.9 2008-05-15 7.0 Tom Link - Fix left offset for inline comments (via operator binding)
tComment.vba.gz 1.8a 2008-05-02 7.0 Tom Link The file autoload/tcomment.vim was packed as autoload/tComment.vim. If you installed 1.8, please rename that file or remove autoload/tComment.vim and use this vimball.
tComment.vba.gz 1.8 2008-05-01 7.0 Tom Link - Definitly require vim7
- Split the plugin into autoload & plugin.
- g:TCommentFileTypes is a list (this could cause problems when updating in certain situations)
- Fixed some block comment strings
- Removed extraneous newline in some block comments.
- Maps for visal mode (thanks Krzysztof Goj)
tComment.vba.gz 1.7 2007-08-30 7.0 Tom Link - gc{motion} (see g:tcommentMapLeaderOp1) functions as a comment toggle
operator (i.e., something like gcl... works, mostly); gC{motion} (see
g:tcommentMapLeaderOp2) will unconditionally comment the text.
- TCommentAs takes an optional second argument (the comment level)
- New "n" map: TCommentAs &filetype [COUNT]
- Defined mail comments/citations
- g:tcommentSyntaxMap: Map syntax names to filetypes for buffers with
mixed syntax groups that don't match the filetypeEmbeddedsyntax scheme (e.g.  
'vimRubyRegion', which should be commented as ruby syntax, not as vim
syntax)
- FIX: Comments in vim*Region
- TComment: The use of the type argument has slightly changed (IG -> i,
new: >)
tComment.vba.gz 1.6 2007-05-01 7.0 Tom Link - Ignore sql when guessing the comment string in php files; tComment
sometimes chooses the wrong comment string because the use of sql syntax
is used too loosely in php files; if you want to comment embedded sql
code you have to use TCommentAs
- Use keepjumps in commands.
- Map <c-_>p & <L>_p to vip:TComment<cr>
- Made key maps configurable via g:tcommentMapLeader1 and
g:tcommentMapLeader2
tComment.zip 1.5 2006-03-22 6.0 Tom Link - "Inline" visual comments (uses the &filetype_inline style if
available; doesn't check if the filetype actually supports this kind of
comments); tComment can't currently deduce inline comment styles from
&comments or &commentstring (I personally hardly ever use them); default
map: <c-_>i or <c-_>I
- In visual mode: if the selection spans several lines, normal mode is
selected; if the selection covers only a part of one line, inline mode
is selected
- Fixed problem with lines containing ^M or ^@ characters.
- It's no longer necessary to call TCommentCollectFileTypes() after
defining a new filetype via TCommentDefineType()
- Disabled single <c-_> mappings
- Renamed TCommentVisualBlock to TCommentRight
- FIX: Forgot 'x' in ExtractCommentsPart() (thanks to Fredrik Acosta)
tComment.zip 1.4 2005-03-16 6.0 Tom Link - Fixed problem when &commentstring was invalid (e.g. lua)
- perl_block
- <c-_>s mapped to :TCommentAs <c-r>=&ft<cr>
tComment.zip 1.3 2005-03-14 6.0 Tom Link - slightly improved recognition of embedded syntax
- if no commentstring is defined in whatever way, reconstruct one from
&comments
- The TComment... commands now have bang variants that don't act as toggles
but always comment out the selected text
- fixed problem with commentstrings containing backslashes
- comment as visual block (allows commenting text to the right of the main
text, i.e., this command doesn't work on whole lines but on the text to the
right of the cursor)
- enable multimode for dsl, vim filetypes
- added explicit support for some other file types I ran into
tComment.zip 0.2 2005-01-11 6.0 Tom Link - Fixed uncommenting of non-aligned comments
- improved support for block comments (with middle lines and indentation)
- using TCommentBlock for file types that don't have block comments creates
single line comments
- the default key bindings have slightly changed
- removed the TCommentAsBlock command (TCommentAs provides its functionality)
- removed g:tcommentSetCMS
tComment.zip 0.1 2005-01-07 6.0 Tom Link Initial upload
ip used for rating: 54.226.120.183

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.
   
SourceForge.net Logo