Detect indentation (TABs or spaces)

  • Dawid Ferenczy

    Dawid Ferenczy - 2012-08-07


    I wonder that Notepad++ cannot detect use of TABs or spaces for indentation in an opened file, because Scintilla component has this behavior for a long time. Scite editor has configuration directive "indent.automatic" which controls that behavior of Scintilla. I think that Notepad++ could set this Scintilla's setting (or property) too to identation detection work properly there, am I right?

    There is a workarround - plugin called "TabIndentSpaceAlign". It use the same indentation character as is on the line before. It's good but not ideal. Moreover it doesn't work with "Python Indent" plugin for example. "Python Indent" uses the Notepad++'s indentation setting instead of using the one detected by "TabIndentSpaceAlign".

    For example:
    - I have set "use tabs" in Notepad++'s settings, so Notepad++ use tabs for indentation everywhere, even in files indented by spaces
    - open file indented by spaces (Python script)
    - because I have "TabIndentSpaceAlign" plugin, it automaticly inserts indentations as spaces (same as on line before)
    - but if I type e.g. "try:" (it's a start of a new block) and hit enter, "Python Indent" runs and inserts indentation according Notepad++'s setting, which is tabs - wrong from my point of view
    (setting "use spaces" in Notepad++ isn't a solution for me because of 99 % of my scripts are tab indented, I need some form of autodetection)

    So, plugin is not an ideal solution. I need something that will be used by other plugins too.

    Back to Scintilla's indent autodetection property. Is there any way to set it even Notepad++ doesn't have a GUI for it?

    There is described a way to send properties directly to Scintilla component on this page:

    I like the way using "NppExec" plugin, because I can set it to run at Notepad++'s startup. So, under Plugins > NppExec > Execute…, I wrote down:

    sci_sendmsg SCI_SETPROPERTY "indent.automatic" "1"

    "indent.automatic" is a configuration file directive for Scite and it should be a Scintilla's property for enabling the indentation autodetection,  I think. When I ran it, Console pops, it look like everything is ok, but indentation autodetection doesn't work. Is it possible, that Notepad++ overrides it with his own unchangeable setting? I tried to restart Notepad++ and it doesn't helps.

    I want to enable automatic indentation detection in Notepad++, no matter what way - sending messages or commands to Scintilla component, using plugin or anyways.

    Thank you.

  • John Peterson

    John Peterson - 2012-11-27

    This is implemented in

    The reason sci_sendmsg SCI_SETPROPERTY "" "1" has no effect is that it's a SciTE rather than a Scintilla setting.

    Last edit: John Peterson 2012-11-27

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks