• Login
Community
  • Login

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

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
10 Posts 6 Posters 21.2k 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.
  • R
    Runemoro
    last edited by Jan 1, 2017, 9:20 PM

    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
    • C
      Claudia Frank
      last edited by Jan 2, 2017, 12:50 AM

      @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
      • G
        gstavi
        last edited by Jan 2, 2017, 6:14 AM

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

        1 Reply Last reply Reply Quote 0
        • G
          gstavi
          last edited by Jan 2, 2017, 9:33 AM

          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
          • A
            Alice Choury
            last edited by Jan 27, 2017, 3:13 PM

            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 ?

            C 1 Reply Last reply Jan 27, 2017, 3:59 PM Reply Quote 0
            • C
              Claudia Frank @Alice Choury
              last edited by Jan 27, 2017, 3:59 PM

              @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
              • C
                Christopher McLaughlin
                last edited by Mar 2, 2017, 5:28 AM

                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.

                C 1 Reply Last reply Mar 2, 2017, 3:02 PM Reply Quote 1
                • C
                  Claudia Frank @Christopher McLaughlin
                  last edited by Mar 2, 2017, 3:02 PM

                  @Christopher-McLaughlin

                  not quite sure what you are referring to?

                  Cheers
                  Claudia

                  1 Reply Last reply Reply Quote 0
                  • N
                    NippurDeLagash
                    last edited by Mar 3, 2017, 7:14 AM

                    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.

                    G 1 Reply Last reply Mar 3, 2017, 11:51 AM Reply Quote 1
                    • G
                      gstavi @NippurDeLagash
                      last edited by Mar 3, 2017, 11:51 AM

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