Skip to content

Instantly share code, notes, and snippets.

@AndrewRadev
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewRadev/11408444 to your computer and use it in GitHub Desktop.
Save AndrewRadev/11408444 to your computer and use it in GitHub Desktop.
Example for the "_dd problem
nnoremap gp :call <SID>CommentedPaste()<cr>
function! s:CommentedPaste()
let text = getreg(v:register)
let commented_lines = []
for line in split(text, "\n", 1)
call add(commented_lines, substitute(line, '\s*\zs\S', '# \0', ''))
endfor
call setreg(v:register, join(commented_lines, "\n"))
exe 'normal! "'.v:register.'p'
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment