Tabs and spaces in autoformatting

Suddenly I found that all my autoformatting use “Tabs as tabs”. I always set 4 spaces for this and always pay attention for this during editor setup. Looks like I made it here too, may be I lost something?
Standard manual formating (not auto) inserts normal spaces like I want. I’m a little bit confused.

And where I can switch on show tabs and spaces on fly like this available in many editors to see the “.” and “>>”?
For example:

Komodo IDE, version 10.2.1, build 89853, platform win32-x86.
Built on Wed Mar 08 12:38:48 2017.

Preferences - Editor - Show whitespace characters.

Is this some sort of script you’re using? Could you explain your exact steps a little more? I don’t know what your doing to diagnose what might be going wrong.

The global preferences look fine. Remember there are Project level and File level preferences as well though. Perhaps those got set?

  • Carey

Excuse me, there were no any notifications in my mailbox. I always forget to set watching topic manually because forums set auto watching if you take part in the topic by default. Watching topic for now.

Defman, thanks, my dots were not too bright and too small comparing to tabs markers. I already found on forum how to make them brighter and bigger (size = 2) with userscript triggered on file open action. Working fine now. That’s exactly what I need. My be it will be fine to make this by default in future.

Carey, that was Magento PHTML template - PHP. Komodo recognize it as PHP ok.
I checked the autoformatting of pure XML file where tabs were formatted as dots. All my dots became tabs also.
I checked all preferences and setting for all levels, no any tabs before spaces option checked anywhere.

@MaxA,

Can you give exactly steps of what you’re doing so I’m not investigating the wrong thing? I’m assuming at this point that you’re using the Editor context menu > Format > Document using > XML Tidy, not Pure XML. There is no Pure XML formatter unless you added one.

  • Carey

I’m seeing this same issue.

Heredoc autoformatting in perl mode (indent set to 2 spaces, spaces preferred over tabs), results in tabs in my heredocs.

@tomwitt2, Heredoc is the formatter? That must be a custom formatter that you setup. Did you change your formatter configuration recently?

@tomwitt2 and @MaxA, What changed recently that coincided with this issue arising?

  • Carey

No, the language mode is Perl mode. (The file ends in .pl so the language mode is automatically set to Perl; I’m not sure what this mode thing is actually called but “language mode” works for me.)

The file preferences with regard to spacing and indentation are set (via Edit Menu -> Current File Preferences -> File Preferences (already expanded) -> Editor -> Indentation) to:
‘Prefer tab characters over spaces’ is unchecked (so spaces preferred)
‘Number of spaces per indent’ is set to 2
‘Width of each Tab character’ is set to 2

When I edit a perl heredoc (like this)

print <<"EOF";

$app_name (Version: $VERSION)

             Show what critical HOOZY WHATSIT processes are running. (Requires >= 5 leading space to show issue)
             THIS LINE IS AUTO INDENTED WITH TABS (WHEN I CLEARLY INDICATED I PREFER SPACES)

             To see the issue while editing, put cursor at end of THIS line and hit return
             next line autoindents with hard tabs
   
Usage: $app_name 

 Option:                      Description:
 --help              | --h    : Show help for script (this screen)
 --debug             | --db   : Write debugging information to the processing log
 --screen            | --s    : Write log to screen as well
 --verbose           | --v    : Do verbose logging
 --start                      : Attempt to start downed scripts
 --remove_lockfiles  | --rl   : Remove the process lockfiles
 
EOF

That second line is automatically indented using hard tabs (and the hard tabs are length 4)

This has been on ongoing issue that I just haven’t had the will to submit a bug report for. When the Komodo forum updates showed me someone else had the problem, that motivated me to share my experience.

My guess is that Komodo recognizes that I’m in a heredoc and puts me into some kind of regular text editing sub-mode and the indentation preferences are not shared with this sub-mode.

Carey, finally you moved me to the right answer. I’m using Beatify JS package for Komodo. Ctrl+Alt+L binded to Beautify menu command and I really had tabs their in setting, [censored]. So, two days of headache and the final point is set at list. Looks like this formatter is the best for me (HTML, js, css and similar). I didn’t sutified with PHP formatting sometimes only. For example:

<?php } ?>

as

<?php } ?>

Did you know some better way in my case?

@MaxA, for PHTML I’m not sure. There might be a formatter out there in the wild that you can add to Komodo through Edit > Preferences > Formatters.

@tomwitt2, I missed languages specific preferences. Check that Perl doesn’t have different settings. You’ll find the language specific prefs in the Global prefs.

  • Carey

Thanks for the information @careyh

I wasn’t really sure what you meant by ‘global preferences’ and a quick web search for ‘komodo global preferences’ led me to this page Komodo indentation tab spaces which mentions global preferences.

Based on information on this page, it turns out the ‘Allow file contents to override Tab and Indentation Settings’, which was turned on, was causing my issue. (I’m still believing it’s because editing a heredoc temporarily switches me out of perl language mode and into a plain-text sub-mode and, with this switch turned on, plain-text sub-mode was overriding my preferred tab and indentations for Perl mode).

Once I disabled the ‘Allow file contents to override Tab and Indentation Settings’ checkbox, I’m getting my expected spacing preferences, even when editing heredocs.

Thanks for the help!

1 Like

“Allow file contents to override Tab and Indentation Settings” uses the first indentation in the file for the indentation settings. So if your first indentation in the file is a tab, Komodo will use tabs, the same for spaces (the width of a space indent will be the amount of spaces in the first indentation, e.g. your line indented with 8 spaces - your indent char will be 8 spaces).

A post was split to a new topic: What formatter do PHP developers use in Komodo?

@MaxA,

I moved your last comment to a new topic since this posts has been resolved. Continuing the new discussion in this thread would make things very confused and not helpful to users finding this thread in the future.

-Care

Where did you come up with that @Defman? It checks up to the first 300 lines, not just the first line.

  • Carey

I just remember a bug with something related to indent. The user were confused by this setting too and we have reproduced that it’s enough to change the indentation in the first line. I’ll try to do that myself though to confirm.

Create a file with this text:

        indent 8
    indent 4
indent 0
            indent 12

Save it, close it, check the setting and open the file. For me the indentation is 8 spaces. If I duplicate the indent 12 line, it does not affect anything - still 8 spaces.

Sorry to be a jerk but you made the statement as if it was a fact. Double check things before you tell people how Komodo works :slight_smile:

This doesn’t seem like enough information to go on when making an assertion about Komodo functionality.

</jerkrant>

  • Carey

I usually do, but this one for some reason was a solid fact in my mind. Can’t explain why though. I’ve tested it to ensure that my mind is not lying to me when we talk about Komodo bugs and issues and it looks like I said the truth - only the first line affects indentation settings. Though my example uses Text, not some actual code, may be the behavior will change if I try to do that in Python or Ruby. Gonna check :slight_smile:

UPD:

https://kopy.io/xAQ3Z

With this Python code, I thought Komodo will use 12 spaces as an indent character (because it’s the most “popular” in the file). But it uses 2 spaces. Should I file a bug for that?

1 Like

That doesn’t seem like a valid test since that’s not valid Python. The syntax checker and interpreter would complain about the first line let alone the mix indent widths throughout the file. Please just file a bug and we can deal with the detection stuff there if it’s broken. We’ve already gone way off topic which I was trying to prevent.

  • Carey