-1

Although the code block does a good job of auto formatting code most of time it does mess up occasionally and when editing often exhibits some strange behavior such as splitting the code block which can result in bad formatting which is not corrected by re-selecting code block.

Is there anyway as a work around you could map a key to produce 4 spaces, It would make life sooo much easier when correcting code layout.

12
  • 2
    I think it's because the tab bar is used by the browser to change focus to the next input box.
    – woz
    Commented Dec 19, 2012 at 18:33
  • yeh I get that, but couldn't Ctrl+space or something similar be mapped to do it
    – SwiftD
    Commented Dec 19, 2012 at 18:34
  • 3
    After you paste the code, just select it all and hit Ctrl-K to indent it all at once.
    – Bill the Lizard Mod
    Commented Dec 19, 2012 at 18:34
  • really? ...I'm gonna go try that
    – SwiftD
    Commented Dec 19, 2012 at 18:35
  • 1
    Yes, really: How do I format my code blocks?
    – Arjan
    Commented Dec 19, 2012 at 18:37
  • No no no, that just does the same thing as the code block button - I know about that, which dont get me wrong works great sometimes. But when you start editing it to strip parts out or add comments it often goes wrong - or if you have tab space mixes. It's when you need to correct it it becomes a pain
    – SwiftD
    Commented Dec 19, 2012 at 18:40
  • 1
    stackapps.com/questions/3247/…
    – balpha StaffMod
    Commented Dec 19, 2012 at 18:47
  • @balpha Just took a look at that link, and that is exactly what I want. But it's not what happens when I use SO, cause if I press tab it moves out the question box. What do I do with the download to make it happen?
    – SwiftD
    Commented Dec 19, 2012 at 18:56
  • Depends on the browser you're using, see stackapps.com/tags/script/info
    – balpha StaffMod
    Commented Dec 19, 2012 at 19:07
  • Then vote for Automatic code reindent button?
    – Arjan
    Commented Dec 19, 2012 at 19:27
  • @Arjan - I've just done that, What I am asking for is what has been suggested as the answer (not whats asked in the question - I suspected that was asking a lot) - increase/decrease indent buttons with a shortcut key
    – SwiftD
    Commented Dec 19, 2012 at 19:35
  • @balpha thanks for the link, I will get that set up
    – SwiftD
    Commented Dec 19, 2012 at 19:36

1 Answer 1

1

What I do is that I write a all of the code I need to the post, or paste all of the code in, then I highlight it and press CTRL + K

1
  • I didnt know about the shortcut but I knew about the code block. I'm speaking more about when the auto-formatting doesnt work properly... which seems to happen a lot especially when editing in the question window
    – SwiftD
    Commented Dec 19, 2012 at 18:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .