I've been trying to post some Java code to my blog, but it seems like it has some problems with the formatting.

First, whenever I copy/paste code into the editor, it's pasted as pre-formatted, which means that it converts the indents to spaces, all on a single line.

And when I try to separate the lines by making each line of code on a single physical line, it doesn't indent them automatically.

I'm using the visual editor, and I've checked the HTML code, and nothing seems to be wrong with it.

What am I doing wrong? Or is this a bug I should report to WordPress?

  • Format the code in a proper text editor first, then just paste it inside the shortcode once you're done. I post code to my WP.com blog without a problem.
    – t31os
    Mar 1, 2011 at 13:56
  • I copied the code to gedit, and I still have the same problem Mar 1, 2011 at 14:12

1 Answer 1


Paste the code in the HTML editor, it probably won't try to convert indents and linebreaks. Surround it with the [sourcecode] shortcode and only then return to the visual editor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.