• Login
Community
  • Login

How to avoid Insertion of tab

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
editing tab
15 Posts 12 Posters 17.6k 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.
  • D
    dail
    last edited by dail Dec 11, 2015, 3:48 PM Dec 11, 2015, 1:39 PM

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

    1 Reply Last reply Reply Quote 0
    • C
      Claudia Frank
      last edited by Dec 11, 2015, 3:45 PM

      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
      • E
        EWKruyt
        last edited by Dec 17, 2015, 1:25 PM

        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.

        C 1 Reply Last reply Dec 17, 2015, 10:33 PM Reply Quote 1
        • C
          Claudia Frank @EWKruyt
          last edited by Dec 17, 2015, 10:33 PM

          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
          • A
            AdrianHHH
            last edited by Dec 18, 2015, 9:03 AM

            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
            • D
              dail
              last edited by dail Dec 18, 2015, 2:07 PM Dec 18, 2015, 2:06 PM

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

              1 Reply Last reply Reply Quote 1
              • A
                Anon Wibble
                last edited by Jun 19, 2017, 3:46 PM

                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
                • G
                  gstavi
                  last edited by Jun 20, 2017, 10:25 AM

                  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
                  • N
                    Nenad Filipovic
                    last edited by Jan 17, 2018, 8:37 AM

                    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
                    • C
                      chcg
                      last edited by Jan 18, 2018, 7:05 PM

                      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
                      • P
                        Paul Dowdle
                        last edited by Jan 26, 2018, 7:07 PM

                        Sorely needed. Please implement.

                        1 Reply Last reply Reply Quote 0
                        • P
                          PeterJones
                          last edited by Jan 26, 2018, 7:44 PM

                          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 Jul 2, 2018, 3:02 PM

                            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 May 14, 2021, 1:19 AM

                              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