Community
    • Login

    Tab replaces all leading spaces

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    18 Posts 6 Posters 5.4k 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.
    • dinkumoilD
      dinkumoil @László Botka
      last edited by dinkumoil

      @László-Botka

      There are two plugins I havn’t tried yet but maybe they could help you.

      The first one is Elastic Tabstops. To obtain some infos about how it works have a look at >>> this site <<<. It can be downloaded via PluginsAdmin as 32 bit and 64 bit version.

      The second one is TabIndentSpaceAlign. It is not available via PluginsAdmin and it’s only 32 bit. You can download it >>> here <<< but you have to install it manually. This plugin was available via the old PluginManager. It hasn’t been included in PluginsAdmin’s plugin list because the DLL file doesn’t contain any version information, which is a requirement. But there are chances that it will run under Notepad++ v7.6 and above.

      1 Reply Last reply Reply Quote 3
      • László BotkaL
        László Botka
        last edited by

        After several years of use, this is the first time that this issue has occurred, in a free format text. Thanks for the recommended macro.

        1 Reply Last reply Reply Quote 2
        • László BotkaL
          László Botka
          last edited by

          @dinkumoil

          Thank you for looking at this.
          I’ll examine them in detail, but from the short descriptions I think they operate under strict rules - I simply want that a Tab pressed be Tab, a space pressed be space in the text.

          @ PeterJones

          It is very unfortunate that Scintilla does not support the above-mentioned operation, the most simple Tab/Space handling , which is naturally supported by the Windows editors like Notepad, Pspad, Ultraedit, FCW editor,

          EkopalypseE 1 Reply Last reply Reply Quote 1
          • EkopalypseE
            Ekopalypse @László Botka
            last edited by

            @László-Botka

            there is a way to work around it, but it involves a scripting plugin.
            One would need to set tab indents attribute to false for each buffer which gets activated.
            I hope I understood your request correctly.

            1 Reply Last reply Reply Quote 4
            • guy038G
              guy038
              last edited by guy038

              Hello, @lászló-botka, @peterjones, @alan-kilborn, @dinkumoil, @ekopalypse, and All,

              Have a look to the article, below :

              https://stackoverflow.com/questions/13973255/notepad-keeping-spaces-in-indent

              Answering to @ellak, the OP, @zennehoy, said something quite pertinent :

              We follow the principle that tabs are used for indentation, and spaces are used for alignment. This allows everyone to choose an indentation size they like, without running into misalignment issues when different people use different indentation sizes. The front two tabs are indentation, the spaces, [coming after], are alignment.


              Indenting problem is rather complex :

              • It depends on the key pressed ( Tab or Shift + Tab )

              • It depends on the position of cursor ( in the “indentation” part or in the “code” part )

              • It may depends of the character right before the cursor location ( a Tab character, a Space character or any other char )

              As for the indentation part of the next line, when hitting the Enter key :

              • It may be changed into a complete space characters area

              • It may be changed into a complete tab characters area, with additional space chars to respect the tabstops

              • It may fully copy the precedent indentation, without any modification


              I tested on N++ v7.6.3, both, the Elastic Tabstops and TabIndentSpaceAlign plugins. To install them :

              • Click on the Plugins > Open Plugins Folder.. option

              • Create a folder TabIndentSpaceAlign and/or a folder ElasticTabstops

              • Stop any Notepad++ instance

              • Place the downloaded dll files, inside its respective folder

              • Restart N++

              After some tests, it happened that the Elastic Tabstops is not suitable for your problem as it is rather used to align areas of text, in columns, separated with tabulation character(s), with elastic tabstops, which may be converted, later, in physical space characters

              Unfortunately, @ekopalypse, your Python work-around isn’t completely useful, too. Indeed, as soon as you hit the Enter key, the default N++ behavior occurs and changes most of the space characters to tabulation chars :-(

              So, @lászló-botka, I do think that the best, for you, would be to install the TabIndentSpaceAlign plugin ;-))


              Once the TabIndentSpaceAlign plugin enabled :

              • A hit on the Tab key, in the “indentation” part of a line :

                • Adds a Tabulation character, if the previous character was a Tabulation character ( of N space size )

                • Adds N space character(s) or less, if the previous characters was a space character

              • A hit on the Tab key, in the “code” part of a line :

                • Adds N space character(s) or less, in all cases ( Hold down the Alt key and hit , successively, on keys 0 and 9, of the numeric keypad, if you really want to insert a tabulation character )

              • A hit on the Shift + Tab key, in the indentation part of a line :

                • Remove the previous Tabulation character, right before the cursor location

                • Remove all the previous area of space character(s), right before the cursor location

              • A hit on the Shift + Tab key, in the code part of a line :

                • Simply move the cursor on the previous tabstop, whatever its location, without deleting* anything

              • A hit on the Enter key rewrites the exact indentation part of the current line in the next line

              Best Regards,

              guy038

              EkopalypseE 1 Reply Last reply Reply Quote 2
              • László BotkaL
                László Botka
                last edited by

                Many thanks to everyone for their help

                @guy038

                The TabIndentSpaceAlign plugin works fine with Alt numpad 09 in the “code” part.
                But it’s complicate to press, and I’m sure I will sometimes press Tab and don’t notice when I write fast.
                …
                I found the solution:
                If I use Ctrl V to Insert Tab (instead of pressing Tab), the result will be what I want: Tabs will be stored as Tab characters, Spaces will be stored as Space characters everywhere.

                [ To achieve this, I already have a hotkey defined with Ditto, an extension to the Windows Clipboard. I use it regularly, to insert a Tab character into the 'Find what" field, searching in Normal mode in the Ctrl+F “Find window”. ]

                1 Reply Last reply Reply Quote 3
                • László BotkaL
                  László Botka
                  last edited by

                  Thanks for the Alt numpad 09 tip, it can also be used in in my original issue, without any extra plugin.

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

                    …Alt numpad 09 tip…

                    It may be worth pointing out that one can easily insert a tab character, without pressing Tab or using the numpad technique, from the ASCII Insertion Panel. Make that panel visible from the Edit menu by choosing Character Panel. Double-clicking any line in that panel inserts the clicked-on character. Useful for others besides tab obviously (although limited to “ASCII” characters).

                    This panel is also a handy reference when you see “black boxed” characters in your (mostly text) file and you’re wanting to know their binary values (perhaps on your way to figuring out how/why they got into your file). You simply mentally note the text inside the black box and compare it to the Character column values on the panel…but let’s not go too far down this road as N++ is a text file editor, not a binary file editor.

                    1 Reply Last reply Reply Quote 3
                    • EkopalypseE
                      Ekopalypse @guy038
                      last edited by

                      @guy038

                      your Python work-around isn’t completely useful, too. Indeed, as soon as you hit the Enter key, the default N++ behavior occurs and changes most of the space characters to tabulation chars :-(

                      does not happen to me.
                      If i hit enter the line stays as it was but if you refer to the next line, then yes,
                      this might happen if you have autoindent enabled but this doesn’t make
                      sense in this case, doesn’t it?

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

                        @Ekopalypse said:

                        this might happen if you have autoindent enabled but this doesn’t make
                        sense in this case,

                        I’m going out on a limb to say that if one is coding, and autoindent is NOT turned on, N++ is too painful to use. :)

                        EkopalypseE 1 Reply Last reply Reply Quote 1
                        • EkopalypseE
                          Ekopalypse @Alan Kilborn
                          last edited by

                          @Alan-Kilborn

                          :-D, but if you like to insert spaces and tabs like YOU want, how should a program know this beforehand??

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

                            @Ekopalypse said:

                            how should a program know this beforehand

                            I’m not following this thread super-closely because in my now 3 decades of software development, the coding standard has been to never allow the use of actual tab characters in source files. But I would think it should replicate the indentation exactly of the line-above, but let the user then edit that and leave it the way the user changes it…but I am too dumb about it to continue talking… :)

                            1 Reply Last reply Reply Quote 2
                            • First post
                              Last post
                            The Community of users of the Notepad++ text editor.
                            Powered by NodeBB | Contributors