2

I was trying to answer a SO question that involved some VBA. The question had a code block, which I copied to my VBA editor (which resulted in some non-indented lines, made some fixes, then put it back on my clipboard.

In the SO answer textbox, I wrote a brief answer, and then clicked the code-block button, and pasted at the insertion point. SO honored the first few lines, but then the non-indented code terminated the code block, and the remainder was treated as normal text/paragraph. Took me a while to realise I needed to add 4 spaces to each of the text/paragraph lines in order to correct it.

Is this something that could/should be handled by JavaScript, when I paste at a code-block inserion point? Or should I just do the indentation in my editor before putting it on the clipboard?

4
  • 4
    You should paste it in first, then select the whole thing and format it as code. That will correctly indent everything.
    – resueman
    Jan 14, 2016 at 21:07
  • Will give it a try later. Jan 14, 2016 at 21:08
  • Also, pre-indenting in your text editor with 4 spaces also works, like you mentioned.
    – ryanyuyu
    Jan 14, 2016 at 21:18
  • Paste the whole code. Select All and click {} option. see this meta.stackexchange.com/questions/207842/… Sep 23, 2021 at 8:01

0

You must log in to answer this question.

Browse other questions tagged .