I am not sure which version of WordPress this started in, but the visual editor likes to remove leading whitespace on every line whenever a post is opened. It used to be that it only did that when you initially pasted text into the editor. So the solution used to be that I would use the text editor and paste the code. Then when switching to the visual editor it would leave my spacing alone. Here is an example of what it is supposed to look like:
However, when I went in to edit that post in 4.8.3 version of WordPress it automatically removed all the leading whitespace from all the code sections. So read up about how to deal with this and it looks like the
<pre>tag is supposed to help with this. However, it makes it look really ugly as it adds another box around the whole thing because of the
[cc lang="cpp"] print("hello world"); [/cc]
Is there a way to tell WordPress that I don’t want the visual editor to reformat my text every time I open the visual editor? I searched the web and the WordPress forums, but have come up with nothing so far. This seems like a really big change as it makes formatting text very difficult now. I really liked my original workflow of switching to the text editor, pasting the code, then switching back.
- The topic ‘Visual Editor Removing Leading Whitespace’ is closed to new replies.