Jump to content

Paste with indent?

Recommended Posts

Several times a day, I paste code into Markdown, e.g. on Github issues. Of course it's pasted exactly as-is, which means that I have to manually add 4 spaces to each line in order for it to be treated as a code block.


It'd be great if there were a workflow which would paste the code, prepending 4 spaces to each line in the process. Does this exist? It seems trivial, but I couldn't find anything out there.


Share this post

Link to post

On GitHub you can use fenced code blocks instead of indenting. It’s a lot easier that way, imo, because you don’t have to change the code.


Otherwise, I dare say you can’t find a workflow to do the indenting because people just use their code editor to do it, or didn’t think it was worth sharing such a trivial workflow.

Share this post

Link to post

As it so happens the code I usually paste usually contains fenced code blocks itself (long story) so I've got to use the indent method ... I do use my code editor today, but it's just such a pain (create new buffer in code editor, paste into code editor, block indent, copy from code editor, close buffer, paste to browser...)


Maybe I'll take a crack at it myself. 🙂 Thanks for the reply!

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...