Go Down

Topic: Arduino IDE produces spaces instead of tabs (Read 3849 times) previous topic - next topic

RageSmirk

It is really a shame that instead of a tab the IDE creates spaces. I've looked at the settings file and I couldn't locate for any entry indicating the IDE to use tabs instead of spaces.  =(

This is very important and ground breaking in regards to aesthetics in coding. The IDE looks very cool but misses this feature greatly, still I consider it a bug instead of a future feature.
On most common editors a tab emulates the size of 4 spaces.
Of course I've found that I can change editor.tabs.size to 4, but this doesn't solve the earlier problem.

Please help.

Grumpy_Mike

OK then use an external editor that does use tabs.

PaulS

Quote
This is very important and ground breaking in regards to aesthetics in coding.

How so? How is a 4 space tab ANY different from 4 spaces, when looking at the code?
The art of getting good answers lies in asking good questions.

RageSmirk


OK then use an external editor that does use tabs.


Can I? Will I be able to code with Visual Studio? Where is the tutorial on how to? Thanks man.

pYro_65


Quote
This is very important and ground breaking in regards to aesthetics in coding.

How so? How is a 4 space tab ANY different from 4 spaces, when looking at the code?


In editors that use tabs properly, the tab width is irrelevant. Its the fact the tabs are spaced from the first column, not relative to the text. So if I had a string of 11 characters and then inserted a 'tab' character, the tab white-space will only occupy 1 character. This allows tabs on each row of text to line up.

Forum Mod anyone?
https://arduino.land/Moduino/

Grumpy_Mike


In editors that use tabs properly, the tab width is irrelevant. Its the fact the tabs are spaced from the first column, not relative to the text. So if I had a string of 11 characters and then inserted a 'tab' character, the tab white-space will only occupy 1 character. This allows tabs on each row of text to line up.

Yes that is fine for that actual operation of producing a file but it looks identical to if they were white spaces.


Can I? Will I be able to code with Visual Studio?

I suppose so. You set the box in the Arduino IDE preferences to use and external editor.
Screen dump attached.

liuzengqiang

I use notepad++ sometimes for edition. It produces real tabs. Arduino 2-space fake tab annoys me only when I start editing arduino code outside the arduino IDE. Nothing lines up and all my comments are screwed up like some kids typed them. This may be a Processing problem, which is the host of the Arduino IDE, i.e. a modified Processing IDE. Seriously if your screen isn't wide enough for a 4-width(not space) tab, get a new one!
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

pYro_65


Yes that is fine for that actual operation of producing a file but it looks identical to if they were white spaces.


That is true, a white space does look like a white space, but irrelevant to the situation.

The IDE adds two spaces regardless of position. To keep vertical columns aligned in the IDE you may be required to either remove or add white space, especially when say formatting lists of array values when they contain an uneven length. Whereas a tab structure would align to the tab boundaries.

Of course you can make them look identical, however one way is simple the other is a pain in the ass. Which is why I use notepad++ for everything apart from the sketch file.


I use notepad++ sometimes for edition. It produces real tabs. Arduino 2-space fake tab annoys me only when I start editing arduino code outside the arduino IDE. Nothing lines up and all my comments are screwed up like some kids typed them. This may be a Processing problem, which is the host of the Arduino IDE, i.e. a modified Processing IDE. Seriously if your screen isn't wide enough for a 4-width(not space) tab, get a new one!


The two space tab may be madness, but I believe method was involved. The IDE has a feature we all dislike called 'copy for forum'.

On the forum, tabs proved a problem, some browsers draw tabs using up to 8 or 10 characters. Others use a CSS property that is set using relative coordinates ( and can be quite large also ).  By using two spaces instead of a tab, the webpage looks a lot cleaner ( usually doesn't require horizontal scrolling ). Sometimes when I post code written outside of the IDE, I will replace all tabs with two spaces, just so it fits better. Notepad++ allows macros which makes the conversion to and from tabs a single click.
Forum Mod anyone?
https://arduino.land/Moduino/

liuzengqiang

Thanks for explaining the forum posting issues Pyro. I didn't think of that. I do have another way to generate tabs in code without using external editor. I manage several related projects that share a lot of defs and variable names. I keep them all in excel so I can look at them and export them any time I need them into actual code. I use string cancat function to assemble a line of declaration and a line of definition and similarly with #define. I can put tabs in my formula instead of space. Tabs look good.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

RageSmirk



In editors that use tabs properly, the tab width is irrelevant. Its the fact the tabs are spaced from the first column, not relative to the text. So if I had a string of 11 characters and then inserted a 'tab' character, the tab white-space will only occupy 1 character. This allows tabs on each row of text to line up.

Yes that is fine for that actual operation of producing a file but it looks identical to if they were white spaces.


Can I? Will I be able to code with Visual Studio?

I suppose so. You set the box in the Arduino IDE preferences to use and external editor.
Screen dump attached.


It just sets the text editor to be read-only, how I benefit from it? Can't Arduino Software Team just fix the tabs problem?

liuzengqiang

Or add an option to use 2-space or real tab.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

CRaitzJ

I was just looking for this issue on the internet, and found out the answer after some thought. I don't know if you could do that in 2014, but now you edit your preferences file to have a real n-space tab character on Arduino IDE, as most experienced programmers would like to. What you have to do is:

  • Close all IDE windows (otherwise it will overwrite your prefs when closing)
  • Go to your IDE preferences.txt file (mine was in MyName\AppData\Local\Arduino15)
  • Change the following two lines:
    editor.tabs.expand=false
    editor.tabs.size=4
  • While you're at it, change the font too:
    editor.font=Consolas,plain,14
    (Consolas is Heavens compared to monospaced)
  • Save and restart the IDE

and happy coding!  :)

Go Up