Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Python indentation support

    Blogs
    5
    10
    15043
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Zeev Atlas
      Zeev Atlas last edited by

      I am not sure whether this is the correct place to post this. I am current in Notepad++ (7.7.1) and despite assertion to the contrary, indentation in .py files (Python), still defaults to tabs rather than to 4 spaces.
      What do I miss?
      ZA

      Ekopalypse Alan Kilborn 2 Replies Last reply Reply Quote 0
      • Ekopalypse
        Ekopalypse @Zeev Atlas last edited by

        @Zeev-Atlas

        I’ve just download a fresh zip, unpacked it a nd tested it.
        Python indentation was done using 4 spaces.

        Could it be that your expectation was that tabs in existing code gets automatically
        converted into spaces?
        If so, no, this doesn’t happen and if you copy/paste source into a python document,
        tabs don’t get converted either.

        1 Reply Last reply Reply Quote 1
        • Alan Kilborn
          Alan Kilborn @Zeev Atlas last edited by

          @Zeev-Atlas

          I don’t know if this is the case for you, but I’d suspect that if you update from an existing version that has tabs as the default, upgrading to a very recent version where spaces are the default…doesn’t change the setting for you (it keeps what you had). Only brand new installs would get the spaces behavior. Or I’m wrong.

          1 Reply Last reply Reply Quote 2
          • Alan Kilborn
            Alan Kilborn last edited by

            Regarding this:

            if you copy/paste source into a python document,
            tabs don’t get converted either.

            …if that’s a key point of interest, then this thread may contain good info:

            https://notepad-plus-plus.org/community/topic/17688/shouldn-t-paste-be-made-respecting-correct-space-at-least-preference

            1 Reply Last reply Reply Quote 2
            • Zeev Atlas
              Zeev Atlas last edited by Zeev Atlas

              I did not expect existing files with tabs to convert, but I expected something like (in an absolutely new file:)

              class a1
              …x=1 # Here I typed four spaces, the dots represent spaces <enter>
              Here notepad++ did a tab, but I expected four spaces

              I suspect that Alan is correct in saying “but I’d suspect that if you update from an existing version that has tabs as the default, upgrading to a very recent version where spaces are the default…doesn’t change the setting for you (it keeps what you had). Only brand new installs would get the spaces behavior.”

              Is there a way to change the default short of totally uninstalling notepad++ and reinstalling?
              Thanks
              ZA

              1 Reply Last reply Reply Quote 0
              • guy038
                guy038 last edited by

                Hi, @zeev-atlas, @ekopalypse, @alan-kilborn and All,

                May be I’ll be totally wrong, but why not use the indentation preferences, in Notepad++ Settings ?


                Among my multiple N++ local versions, the last one, where I installed the Python plugin, is the v7.6.3 version.

                After a quick test, in a new Python file, I confirm that hitting the TAB key wrote a tabulation char ( \x09 ), as mentioned by @zeev-atlas !

                Now :

                • Go to Settings > Preferences... > Language > Tab Settings

                • Select the Python item, near the end of the drop-down list

                • Untick the use default value option

                • Verify that the tab size value is 4

                • Tick the Replace by space option

                • Click to the Close button to valid the changes close the Preferences dialog

                => From now on, any hit on the TAB key will write, automatically, 4 spaces as leading indentation ;-))


                Again, I may have completely misunderstood the problem !

                Best Regards,

                guy038

                Ekopalypse Alan Kilborn 2 Replies Last reply Reply Quote 0
                • Ekopalypse
                  Ekopalypse @guy038 last edited by

                  @guy038

                  no you are not wrong, as of npp 7.7 the standard, for python, is to use spaces instead of tabs.

                  1 Reply Last reply Reply Quote 0
                  • Alan Kilborn
                    Alan Kilborn @guy038 last edited by

                    @guy038

                    The original complaint was that Notepad++ (7.7.1) ... indentation in .py files (Python), still defaults to tabs rather than to 4 spaces

                    And this is simply not true. Notepad++ 7.7.1 defaults .py file indentation to spaces, not tabs.

                    Sure, it is easily changeable, but that’s not what we’re talking about here. We’re talking about what it defaults to.

                    1 Reply Last reply Reply Quote 0
                    • richard turner
                      richard turner last edited by

                      Thanks for all the tips mentioned in this article! it’s always good to read things you have heard before and are implementing, but from a different perspective, always pick up some extra bits of information.

                      Alan Kilborn 1 Reply Last reply Reply Quote 0
                      • Alan Kilborn
                        Alan Kilborn @richard turner last edited by

                        @richard-turner

                        Your posting in this thread is OK, but your profile points in the other direction. Tread lightly.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Copyright © 2014 NodeBB Forums | Contributors