Community
    • Login

    How can I set Notepad++ to indent with spaces?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    10 Posts 6 Posters 22.4k Views 2 Watching
    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.
    • RunemoroR Offline
      Runemoro
      last edited by

      I would like Notepad++ to automatically indent using spaces if the previous line is indented using spaces, and with tabs if the previous line is indented using tabs. I know that this can be done by enabling the “Replace tabs with spaces” option, but I wouldn’t like to lose the ability to add tabs when I want to.

      1 Reply Last reply Reply Quote 0
      • Claudia FrankC Offline
        Claudia Frank
        last edited by

        @Runemoro

        currently, I don’t see that this can be solved by using npp builtin features/settings
        and I’m not aware of a plugin which does this.

        I can think of a python script doing it if you are willing to install python script plugin.
        In case you are - please don’t install the plugin via plugin manager instead use the msi
        package from here.

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 0
        • gstaviG Offline
          gstavi
          last edited by

          I patched my version of NPP for doing that.
          Here is the patch.
          Here are binaries.

          1 Reply Last reply Reply Quote 0
          • gstaviG Offline
            gstavi
            last edited by

            There are at least 3 related fixes that I wanted in this area and implemented for myself.

            1. New line will be indented according to the indentation style of previous line.
            2. When a line indent is modified (add/remove tab) the indent will be according to current indent style and not according to global style.
            3. When pressing multiple ENTERs to add blank lines the last line should be indented automatically but blank lines should be empty and not with indent whitespace.

            Can’t tell if everyone will be happy with such behavior but when working with code from multiple sources and attempting to respect each source style current Notepad++ indentation is quite annoying.

            1 Reply Last reply Reply Quote 0
            • Alice ChouryA Offline
              Alice Choury
              last edited by

              In old version this function existed.
              Why it doesn’t exist now ?
              How can we do to get 4 spaces when we press the tab ?

              Claudia FrankC 1 Reply Last reply Reply Quote 0
              • Claudia FrankC Offline
                Claudia Frank @Alice Choury
                last edited by

                @Alice-Choury

                your question is different to what the original poster asked for
                but luckily yours can be solved easily by checking
                Replace by space under Settings->Preferences->Language

                Cheers
                Claudia

                1 Reply Last reply Reply Quote 1
                • Christopher McLaughlinC Offline
                  Christopher McLaughlin
                  last edited by

                  I find it pretty ridiculous that this isn’t a default behavior. If I select multiple lines of text, it is not unreasonable to expect that they will paste in the same relative position to each other.

                  Claudia FrankC 1 Reply Last reply Reply Quote 1
                  • Claudia FrankC Offline
                    Claudia Frank @Christopher McLaughlin
                    last edited by

                    @Christopher-McLaughlin

                    not quite sure what you are referring to?

                    Cheers
                    Claudia

                    1 Reply Last reply Reply Quote 0
                    • NippurDeLagashN Offline
                      NippurDeLagash
                      last edited by

                      Quoted:

                      if the previous line is indented using spaces, and with tabs if the previous line is indented using tabs

                      I’m curious. Why do you need such a behaviour? You are not editing source code, I guess.

                      gstaviG 1 Reply Last reply Reply Quote 1
                      • gstaviG Offline
                        gstavi @NippurDeLagash
                        last edited by

                        @NippurDeLagash
                        My reason for needing such behavior is that a source project has many authors. Think of multiple libraries. Coding style is not always strictly enforced (it is a different debate if it should be). And while I may modify any source file during development or debugging it is a good habit that a small fix will respect the original style of the code surrounding it.

                        1 Reply Last reply Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors