48

When you type a code, and you press enter, the new line should be filled with x*4 spaces or x tabs. It's not that comfortable to copy tabs/spaces from the previous line, or paste the code to notepad, format it, then paste it back into this editor.

10
  • 4
    Closely related: Markdown editor tab key functionality, and the user script fix. Jul 19, 2015 at 11:12
  • 3
    Also take a look at Feedback Requested: Code Editor and Stack Snippets. Jul 19, 2015 at 12:19
  • It's not so hard to keep 4 spaces copied in clipboard and paste them for each new line... Jul 19, 2015 at 18:06
  • 2
    @CliffBurton: You can use Google, why is there +1 search bar...? It's not se hard for supporting it, like +20 lines in the js file?
    – klenium
    Jul 19, 2015 at 18:19
  • 2
    @CliffBurton That's pretty unreasonable. It may not be hard, but it means that I can't copy/paste anything else without overwriting those spaces in the clipboard.
    – DavidG
    Jul 20, 2015 at 13:07
  • To @DavidG and klenium - check here and here They are not auto indent but you can press Tab and keep in clipboard whatever you want Jul 20, 2015 at 14:31
  • @CliffBurton I'm well aware of those scripts, I just wish (believe?) that the editor should do it by default.
    – DavidG
    Jul 20, 2015 at 14:47
  • 2
    @CliffBurton: Yeah, I know there're scripts for it, or I could've written my own. But isn't eg jsfiddle better than stackoverflow + userscript + a plugin that runs it? Why you don't want it to be added to the editor?
    – klenium
    Jul 20, 2015 at 16:38
  • Ehm..I never told I don't want it to be implemented to the editor, I too as soon as I joined this site had tons of ideas to make it better, and mine stackoverflow is full of userscripts, because if I want something I do it by myself. Those scripts are on SE since '12 and I think that all the SE programmers and managers are aware of them, If they had wanted to do it they would have already done ... I think Jul 20, 2015 at 17:58
  • The "you can just do more complicated thing X" comments are mind-blowing. How about just writing letters and posting them on the city hall walls to get help with your programming issues - who needs StackOverflow or the internet anyway? This (and many questions relating to indentation with it) is a perfectly valid request and the current editor failure to deal with it appropriately is mind-blowing, considering how many online editors get it right. How about ```?
    – Grismar
    Mar 18, 2019 at 7:56

2 Answers 2

-3

What I do in VS 2015 is:

  1. Select all my code and then press CTRL + SHIFT + TAB so it is indented as far left as possible. If you do not do this, it will have many tabs and then you would need to manually fix each line on stackoverflow.
  2. Then copy and paste on StackOverflow edit and select it all and press CTRL + K.

That is the best method I have found so far.

-9

What you do is type your code and then highlight and press ctrl+k. I have done this a couple times and it works perfectly.

4
  • 8
    This is the approach I use, which works until it doesn't - such as when I'm adding lines to an existing code block. Jul 19, 2015 at 22:24
  • After the first block of code with white space, I have to manually reformat after that. But maybe the flip side is that this inconvenience encourages us to paste as little code as possible so that we focus on the most important content.
    – user4864716
    Jul 20, 2015 at 5:11
  • And as soon as you want to present correctly indented code, you count 4, 8, 12 spaces. Is is generally enough when pasting code from an IDE even if tabs can give strange results but taking code from a question and adding some line can be tedious Jul 20, 2015 at 5:44
  • Why the downvotes?
    – clickbait
    May 29, 2017 at 19:14

You must log in to answer this question.

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