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.
3939{Visual} gcy Yank and then comment or uncomment the highlighted
4040 lines.
4141
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+ <
4261The | User | CommentaryPost autocommand fires after a successful operation and
4362can be used for advanced customization.
4463
You can’t perform that action at this time.
0 commit comments