Support » Themes and Templates » Code – Indent Lines

  • I’m a developer and like to put use ‘code’ tags in posts. Most code is indented from line to line although HTML ignores these indents/tabs, what’s the easiest way to post file with lots and lots of indents? As it is now, wordpress ignores indents/spaces I put inside of block blogs at the beginning of lines.

    I know I can setup a style to indent one line but lets say I’m posting a java file with 10 levels of idents… I really don’t want to wrap every single line with a different block level. Ideally, I’d like some way for the text inside the ‘code’ block to be fixed width including spaces and line breaks. Anyone have any ideas?

Viewing 11 replies - 1 through 11 (of 11 total)
  • wordpress uses blockquotes tag. can you just use that?

    insert code here and go

    I found that using the SyntaxHighlighter Plus plugin is the best way to post code. (Go to the Extend section)

    No mrkingid. Read my post again. What if I want to indent 10 different levels… it would look like this:

    public something() {

    var x;
    if(…) {

    for(…) {

    while(…) {

    // Something

    // Something else




    On top of that the code to write what I just did is a horrible mess to type with. Please read the post in full before responding.

    Um… SyntaxHighlighter Plus plugin does not automatically indent (and ignores spaces), so again, not helpful to my problem.

    If you copy indented code lines into the post area and add the SHP code before and after – it keeps the indent.

    I wish SyntaxHighlighter Pus did, when I tried not only did it not indent previously indented code but the plug itself was broken. Line numbers were cut off vertically. Definitely needs more work.

    On the other hand I did discover Code Snippet Plugin which is far better (simple interface without need to disable annoying buttons in snippet) and pays attention to my indention.

    For code, use the tag

     which stands for "preformatted".

    gah, it messed up what I tried to enter. You want to use the pre tag (with less-than and greater-than symbols on each side).

    But with the Code Snippet Plugin I don’t need to do that. Why use two tags (one of which is broken as I mentioned) when one will suffice?

    ApolloX. I did read your post but obviously was mistaken.
    [moderated – according to forum rules]

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    I’ve had good success with the WP-Syntax plugin. It allows you to use line numbering and such if you want, preserves indents, and does code highlighting using Geshi, if you specify the language the code is in. Very neat.

    It uses Javascript to do all the highlighting, making copy/pasting continue to work properly, and it uses pre tags as the signal around the code, meaning that if the javascript doesn’t work, then it fails back to functional HTML.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Code – Indent Lines’ is closed to new replies.