Community
    • Login

    How to avoid Insertion of tab

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    editing tab
    15 Posts 12 Posters 17.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.
    • EWKruytE
      EWKruyt
      last edited by

      When you start a new line in NP++ the new line is aligned with the previous.
      However, instead of inserting the same leading blanks as the previous line, a tab is inserted if the number of blanks equals the tab setting.
      This is highly unwanted in my opinion.
      How can I switch this behavior off?

      1 Reply Last reply Reply Quote 1
      • dailD
        dail
        last edited by dail

        Settings > Preferences > MISC. and turn off auto-indent. Helps if I read then entire post :)

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

          Hello,

          to prevent that tab instead space gets inserted goto
          Settings -> Preferences -> Tab Settings and check Replace by Space

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 0
          • EWKruytE
            EWKruyt
            last edited by

            In that case all tabs are always replaced by spaces.
            I just want that the indent of the previous line is kept as it is:
            either tab or spaces.

            Claudia FrankC 1 Reply Last reply Reply Quote 1
            • Claudia FrankC
              Claudia Frank @EWKruyt
              last edited by

              Hello EWKruyt,
              afaik this isn’t possible yet.
              May I ask you why it is important for you to have this feature?
              At the moment I don’t see any benefit, which doesn’t mean there
              isn’t one, maybe you can enlight me?

              Cheers
              Claudia

              1 Reply Last reply Reply Quote 0
              • AdrianHHHA
                AdrianHHH
                last edited by

                Claudia,

                An example.

                My default settings are to keep tabs as tabs, but I have some file types (eg Perl scripts) set to replace tabs with spaces.

                I often create new small file Perl script files. I just type the entire script into a new and empty buffer, then do a Save as with a .pl extension. As I type I enter spaces for indents. After hitting enter, the newline is indented with tabs. As I want spaces to indent these Perl files I have to use the Edit => Blank operations => Tab to spaces command on the whole file just before or just after the Save as.

                It would be more convenient for me if the auto indent copied the leading white space of the previous line. The current behaviour is to use the default tab settings to produce an indent of the same size as the line above.

                This behaviour is a minor inconvenience to me. I had not considered it worthy of a feature request, but you asked for why it may be useful.

                Adrian

                1 Reply Last reply Reply Quote 0
                • dailD
                  dail
                  last edited by dail

                  With a quick Google search I ran across the TabIndentSpaceAlign plugin (available in the PluginManager).

                  1 Reply Last reply Reply Quote 1
                  • Anon WibbleA
                    Anon Wibble
                    last edited by

                    Hi,

                    I really want this this feature too.

                    I use visual stupid, and notepad++ to store visual studio data notes when I am debugging - namely things like call stacks…

                    These look like:

                    Function 1
                    Function 2
                    Function 3
                    etc

                    Now I’d like to go back to the margin after a blank space “^\n$” or whatever the silly windows newline is this week, but instead it starts off with a tab at the start, so when i next paste the call stack i get:

                    [unwanted tab] > Function A
                    Function B
                    Function C
                    etc.

                    I don’t want this, i want:

                    Function 1
                    Function 2
                    Function 3
                    etc

                    So that I don’t have to go back through every single tab that your editor inserted.

                    I love notepad++, but this is soo irritating because this comes up for me 20-30 times a day. I really think this would make your editor soo much less irritating to use.

                    Cheers!

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

                      I really wanted this feature too.
                      So I compiled Notepad++ from sources and modified the behavior. With a few other tweaks I wanted.

                      Here are the source patches: https://github.com/gstavi/npp/tree/master/patch
                      Here are NPP binaries

                      On the other hand the base version I am using is still 6.7.8

                      1 Reply Last reply Reply Quote 0
                      • Nenad FilipovicN
                        Nenad Filipovic
                        last edited by

                        I also vote this feature should be implemented ASAP. That is - indent of the previous line must be preserved. I work with lots of different file types, some are space indented, and some tab indented - that’s simply how world is. Having to Edit->Blank Operations->Tab to space 50 times a day is really frustrating.

                        1 Reply Last reply Reply Quote 0
                        • chcgC
                          chcg
                          last edited by

                          As a workaround you could add a keyboard shortcut for Edit->Blank Operations->Tab to space under Settings->Keyboard…

                          1 Reply Last reply Reply Quote 2
                          • Paul DowdleP
                            Paul Dowdle
                            last edited by

                            Sorely needed. Please implement.

                            1 Reply Last reply Reply Quote 0
                            • PeterJonesP
                              PeterJones
                              last edited by

                              Workaround: record a macro, and assign it to a useful key, so that it will do the tab-space or space-tab conversion every time you save. (That way, it will happen automatically on a keyboard-shortcutted save, rather than having to do the multi-menu pulldowns 20-30 times per day. Note: this method will not intercept clicking on the SAVE icon on the toolbar, or on File > Save; but if you use a keyboard shortcut to save, then this can be just as automatic.)

                              • If you want tab-to-space:

                                1. Macro > Start Recording
                                2. Edit > Blank Operations > TAB to space
                                3. File > Save
                                4. Macro > Stop Recording
                                5. Macro > Save Current Recorded Macro
                                  • Name: TabToSpaceSave
                                  • You can assign keyboard shortcut using the ☐ Ctrl ☐ Alt ☐ Shift boxes, using the dropdown to select which character.
                                    • If you want this to be your default Ctrl+S save, you can even replace that (though you’d also have to use the Settings > Shortcut Mapper to modify the normal Save’s keyboard shortcut. (I actually did that, so Trim Trailing Spaces and Save is my default Ctrl+S action)
                                  • OK
                              • If you want leading space to TAB:

                                1. Macro > Start Recording
                                2. Edit > Blank Operations > Space to TAB (leading)
                                3. File > Save
                                4. Macro > Stop Recording
                                5. Macro > Save Current Recorded Macro
                                  • Name: LeadingSpaceToTabSave
                                  • Assign keyboard shortcut, if desired
                                  • OK

                              Or, you can manually add the XML that I got when I recorded those two macros, to your %appdata%\notepad++\shortcuts.xml. (note: because NPP overwrites shortcuts.xml on exit, you may have to gasp use a different text editor to insert these lines. I was able to make it work in NPP by closing all instances of NPP, open NPP, edit the shortcuts.xml file, save, and exit – without changing any NPP settings… but I don’t guarantee that it will work for you.)

                                  <Macro name="TabToSpaceSave" Ctrl="no" Alt="no" Shift="no" Key="0">
                                      <Action type="2" message="0" wParam="42046" lParam="0" sParam="" />
                                      <Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
                                  </Macro>
                                  <Macro name="LeadingSpaceToTABSave" Ctrl="no" Alt="no" Shift="no" Key="0">
                                      <Action type="2" message="0" wParam="42053" lParam="0" sParam="" />
                                      <Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
                                  </Macro>
                              

                              Close shortcuts.xml. Exit and reload Notepad++. Now those macros should exist in your Macro menu. You can then use the Settings > Shortcut Mapper > Macros to edit the assigned keystrokes for each version.

                              1 Reply Last reply Reply Quote 2
                              • László FülöpL
                                László Fülöp
                                last edited by

                                In Notepad++ version 7.5.1 Claudia’a solution is working!
                                You can change the tab settings by language, so go to:
                                Settings -> Preferences -> Tab Settings,
                                select your language on the right side of the dialog,
                                and check Replace by Space

                                I’m not sure which is the first version that uses this kind of config, but I have used it for some time now.

                                1 Reply Last reply Reply Quote 0
                                • Allan FordA
                                  Allan Ford
                                  last edited by

                                  Option now (version 7.9.5 May 2021) … as per Settings > Preferences > Language > Tab Settings … Check the “Replace by space” option.

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