File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,25 @@ gcy Yank and then comment or uncomment [count] lines.
39
39
{Visual} gcy Yank and then comment or uncomment the highlighted
40
40
lines.
41
41
42
+ You can implement a "duplicate-and-comment" operation, i.e., where text is
43
+ yanked, commented/uncommented, and then the original text is pasted again by
44
+ something like the following: >
45
+
46
+ function! s:yankcommentpaste(type,...)
47
+ if a:0
48
+ let [mark1, mark2] = [a:type, a:1]
49
+ else
50
+ let [mark1, mark2] = ["'[", "']"]
51
+ endif
52
+ let savereg = @"
53
+ execute "normal " . mark1 ."gcy" . mark2 . "]"
54
+ execute "normal! " . mark2 . "p" . mark1
55
+ let @" = savereg
56
+ endfunction
57
+ xnoremap <silent> dc :<C-U>call<SID>yankcommentpaste("'<", "'>")<CR>
58
+ nnoremap <silent> dc :<C-U>set opfunc=<SID>yankcommentpaste<CR>g@
59
+ nnoremap <silent> dcc :<C-U>set opfunc=<SID>yankcommentpaste<Bar>exe 'norm! 'v:count1.'g@_'<CR>
60
+ <
42
61
The | User | CommentaryPost autocommand fires after a successful operation and
43
62
can be used for advanced customization.
44
63
You can’t perform that action at this time.
0 commit comments