• Login
Community
  • Login

Python indentation support

Scheduled Pinned Locked Moved Blogs
10 Posts 5 Posters 22.3k Views
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.
  • Z
    Zeev Atlas
    last edited by Aug 18, 2019, 6:28 PM

    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

    E A 2 Replies Last reply Aug 18, 2019, 7:53 PM Reply Quote 0
    • E
      Ekopalypse @Zeev Atlas
      last edited by Aug 18, 2019, 7:53 PM

      @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
      • A
        Alan Kilborn @Zeev Atlas
        last edited by Aug 19, 2019, 1:15 AM

        @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
        • A
          Alan Kilborn
          last edited by Aug 19, 2019, 1:18 AM

          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
          • Z
            Zeev Atlas
            last edited by Zeev Atlas Aug 20, 2019, 3:55 AM Aug 20, 2019, 3:54 AM

            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
            • G
              guy038
              last edited by Aug 20, 2019, 9:35 AM

              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

              E A 2 Replies Last reply Aug 20, 2019, 11:19 AM Reply Quote 0
              • E
                Ekopalypse @guy038
                last edited by Aug 20, 2019, 11:19 AM

                @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
                • A
                  Alan Kilborn @guy038
                  last edited by Aug 20, 2019, 12:31 PM

                  @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
                  • R
                    richard turner
                    last edited by Aug 20, 2019, 12:56 PM

                    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.

                    A 1 Reply Last reply Aug 20, 2019, 1:17 PM Reply Quote 0
                    • A
                      Alan Kilborn @richard turner
                      last edited by Aug 20, 2019, 1:17 PM

                      @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
                      10 out of 10
                      • First post
                        10/10
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors