Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.

Vim trick: Paste text as Markdown blockquote

I just put this together tonight:

nmap <localleader>bq pmaV`]gw`a:s/^/> /g<CR>:nohlsearch<CR>o

Now copy some text (multiple paragraphs should work too) and in Normal mode do <localleader>bq. The paragraphs should be pasted, wrapped, and prefixed with >.


  • p: paste
  • ma: set mark a
  • V`]: re-select the pasted text
  • gw: format
  • `a: select back to mark “a”
  • :s/^/> /g: replace beginning of line with >
  • :nohlsearch: remove the highlight from the previous command
  • add new line and enter insert mode

Update: I think the following shorter version should work too: pgw`]V`]:s/^/> /g.... It uses the paste markers instead of jumping back and forth and setting new ones.

Don't be the product, buy the product!