tomtom / tcomment_vim

An extensible & universal comment vim-plugin that also handles embedded filetypes

Home Page:http://www.vim.org/scripts/script.php?script_id=1173

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature request] Comment and duplicate command

nwaywood opened this issue · comments

A command that in addition to commenting (like gcc/gc) also pastes an uncommented version of the code below the commented out version.

For example:

Before running this command

some 
code
block

After running this command with the three lines selected in visual mode

// some
// code
// block
some
code
block

Something like the following:

 gD{motion}   :: Comment and duplicate
 gDD         :: Comment and duplicate for the current line

In visual mode:

 gD           :: Comment and duplicate

I hope you like the idea!

I think this should be done as a custom vim map on top of tcomment. I don't see a convincing reason why this should be included in tcomment. You might also want to consider using a VCS instead of duplicating code.

@tomtom Any chance you could show how a custom vim map could use tcomment to do this? I tried without much success... (I'm not a vimscript pro)