ToggleComment : Simple, flexibel, language-independent mappings to de-/commentify
| script karma
Downloaded by 1484
Comments, bugs, improvements
script versions (upload new version)
|This utility draws heavily from vimtip #271 and additional note 2002-07-06.
Yet it's different in one or more aspects from other tips and scripts I'm
- de-/commtify lines in normal mode (with count) and visual mode
- use the same keys for commenting and decommenting
- language independent, you define different mappings for various languages
and/or one comment-command for different filetypes
- simple and flexibel, to change the comment characters from '#' to '# ' e.g.,
just change a mapping in your .vimrc, not the script
- comment-style: comments are indented like the uncommented line
- no hlsearch problem, last search pattern and .-command are preserved
- inserted comment characters are protected from further expansion
- might be adapted to other comment styles (first column comments, ...)
Commented text looks like this:
/* comment the line */
<!-- else: -->
// uncomment the
You would put or remove this comments (cursor on the first line), by typing:
,# ,* ,< 2,/
|Put the file ToggleComment.vim in your plugin directory or just copy/paste
the two functions in your .vimrc file.
Then define mappings in your .vimrc, like for example:
map ,# :call CommentLineToEnd('#')<CR>+
map ,* :call CommentLinePincer('/* ', ' */')<CR>+
and/or map Meta-c (Alt-c) and Meta-Shift-C for different FileTypes.
For more detailed description and installation instructions see the README file.
Click on the package to download.
ip used for rating: 184.108.40.206