Code formatting changing when file saved/loaded lazarus / 9-Editor ---------------------------------------------------------------------- MoonWolf · 2015-10-13 17:28 Hi, I am using Lazarus 1.4.2 for Windows with FPC  2.6.4. I am having a problem with code formatting. For example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function caaCalcMass(WeightInGrains : extended): extended;begin  result := (WeightInGrains / GrainsPerPound) / GravityConstant;end; The above code can change to. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function caaCalcMass(WeightInGrains : extended): extended;begin        result := (WeightInGrains / GrainsPerPound) / GravityConstant;end; I can live with this, but it is annoying. I have used Lazarus for several years and this is the first time I have seen this behavior. Has anyone else got this problem? Thanks. ---------------------------------------------------------------------- rvk · 2015-10-13 18:28 What are your settings under: Tools > Options > Editor > General > Tab and Indent Do you have it set like attached image? (It seems like you have a tab in front of "Result :=".) ---------------------------------------------------------------------- MoonWolf · 2015-10-13 22:55 Quote from: rvk on October 13, 2015, 08:28:47 pmWhat are your settings under: Tools > Options > Editor > General > Tab and Indent Do you have it set like attached image? (It seems like you have a tab in front of "Result :=".) My settings are identical to the settings in the attached image. I think the tab in front of "Result :=" is the case. I have had problems in the past with auto indent. So when I set up 1.4.2 I don't think I made any changes to the default settings. ---------------------------------------------------------------------- rvk · 2015-10-14 08:59 You could try renaming your editoroptions.xml to editoroptions-old.xml in your config-directory and starting Lazarus. A new editoroptions.xml will be made and your back to the default options for the editor- settings. If that doesn't work you could do the same with codetoolsoptions.xml. (I would also be really annoyed if tabs kept appearing where I didn't want them.) ---------------------------------------------------------------------- MoonWolf · 2015-10-14 14:35 Thank you for your suggestions. I will give them a try. ---------------------------------------------------------------------- shobits1 · 2015-10-14 18:10 maybe you should change the tab to spaces width to only 2 instead of 8. ---------------------------------------------------------------------- rvk · 2015-10-14 18:20 Quote from: shobits1 on October 14, 2015, 08:10:30 pmmaybe you should change the tab to spaces width to only 2 instead of 8. You could do that but it would only mask this annoyance. I know from experience that if you mix tab and spaces it can be very confusing and annoying. Even when the tab is set at 2 spaces when you put one space in front of it it will not jump. Putting another space it will jump 2 spaces. Very very annoying. It's better to find out why this is happening. (This is why I hate tabs in source-code but that was another discussion from a while ago) ---------------------------------------------------------------------- shobits1 · 2015-10-14 20:45 Quote from: rvk on October 14, 2015, 08:20:39 pmI know from experience that if you mix tab and spaces it can be very confusing and annoying. I totally agree with you, but I thought when `Tab to spaces` is checked the editor automatically replaces tabs by the required spaces (or am I wrong?). maybe I didn't understand `MoonWolf` question? ---------------------------------------------------------------------- rvk · 2015-10-14 20:49 Quote from: shobits1 on October 14, 2015, 10:45:18 pmbut I thought when `Tab to spaces` is checked the editor automatically replaces tabs by the required spaces (or am I wrong?).Yes, but that setting was already set correctly. Apparently the spaces are there on saving the file but when loading it again they turn into tabs. And that may never happen. ---------------------------------------------------------------------- MoonWolf · 2015-10-14 22:17 Quote from: rvk on October 14, 2015, 10:59:22 amYou could try renaming your editoroptions.xml to editoroptions-old.xml in your config- directory and starting Lazarus. A new editoroptions.xml will be made and your back to the default options for the editor-settings. If that doesn't work you could do the same with codetoolsoptions.xml. (I would also be really annoyed if tabs kept appearing where I didn't want them.) This is odd.  The only copy of editoroptions.xml is located in "D:\lazarus\tools\install\linux" and it is dated 2007. I can't find the other file at all. ---------------------------------------------------------------------- MoonWolf · 2015-10-14 22:22 rvk - As a temporary expedient I'm going to avoid using the tab key and stick with spaces. shobits1 - I've tried that on previous versions of Lazarus and got some peculiar results from auto-indent. Thanks for the replies. ---------------------------------------------------------------------- rvk · 2015-10-15 08:54 Quote from: MoonWolf on October 15, 2015, 12:22:00 amAs a temporary expedient I'm going to avoid using the tab key and stick with spaces. Mmm, that shouldn't matter if, when loading, Lazarus makes them Tabs again. But if it does, then you didn't explain the problem correctly. I thought you saw spaces before saving and a tab after loading. Could you do the following? Under Tools > Options > Editor > Misc: Set the "Show special characters". Now you can see, if you use the tab, if there is really a tab set (it shows » character as tab) or the tab is converted to spaces (· characters). What do you see? (It's important to know if it has a tab before saving.) If it has tabs, your "Tabs to spaces"-setting doesn't work. If it does have spaces, save the file and look with a bin/hex-editor if the spaces are $20 of $09. Which are they? Now load the file again and see if the spaces are converted to tabs. ---------------------------------------------------------------------- MoonWolf · 2015-10-15 16:39 Quote from: rvk on October 15, 2015, 10:54:29 amMmm, that shouldn't matter if, when loading, Lazarus makes them Tabs again. But if it does, then you didn't explain the problem correctly. I thought you saw spaces before saving and a tab after loading.It appeared to me that Lazarus was making them tabs again. I spent several hours trying to figure this out before posting here. I should have spent more time. Now the problem appears to be user error on my part.    Quote from: rvk on October 15, 2015, 10:54:29 amCould you do the following? Under Tools > Options > Editor > Misc: Set the "Show special characters". Now you can see, if you use the tab, if there is really a tab set (it shows » character as tab) or the tab is converted to spaces (· characters). What do you see? (It's important to know if it has a tab before saving.)All the tabs I entered were converted to spaces  (· characters). No tab characters ( » ) are present. Quote from: rvk on October 15, 2015, 10:54:29 amIf it has tabs, your "Tabs to spaces"-setting doesn't work. If it does have spaces, save the file and look with a bin/hex-editor if the spaces are $20 of $09. Which are they? $20. Quote from: rvk on October 15, 2015, 10:54:29 amNow load the file again and see if the spaces are converted to tabs. The spaces are remaining spaces. Thanks for the tip on showing special characters. I can only conclude that I was saving tabs when I thought I was saving spaces.  I would like to thank those who responded and I apologize for wasting their time.