How to avoid Insertion of tab
-
Hello,
to prevent that tab instead space gets inserted goto
Settings -> Preferences -> Tab Settings and check Replace by SpaceCheers
Claudia -
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. -
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 -
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
-
With a quick Google search I ran across the TabIndentSpaceAlign plugin (available in the PluginManager).
-
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
etcNow 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
etcSo 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!
-
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 binariesOn the other hand the base version I am using is still 6.7.8
-
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.
-
As a workaround you could add a keyboard shortcut for Edit->Blank Operations->Tab to space under Settings->Keyboard…
-
Sorely needed. Please implement.
-
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:
Macro > Start Recording
Edit > Blank Operations > TAB to space
File > Save
Macro > Stop Recording
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 theSettings > Shortcut Mapper
to modify the normal Save’s keyboard shortcut. (I actually did that, so Trim Trailing Spaces and Save is my defaultCtrl+S
action)
- If you want this to be your default
OK
- Name:
-
If you want leading space to TAB:
Macro > Start Recording
Edit > Blank Operations > Space to TAB (leading)
File > Save
Macro > Stop Recording
Macro > Save Current Recorded Macro
- Name:
LeadingSpaceToTabSave
- Assign keyboard shortcut, if desired
OK
- Name:
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 theshortcuts.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 theSettings > Shortcut Mapper > Macros
to edit the assigned keystrokes for each version. -
-
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 SpaceI’m not sure which is the first version that uses this kind of config, but I have used it for some time now.
-
Option now (version 7.9.5 May 2021) … as per Settings > Preferences > Language > Tab Settings … Check the “Replace by space” option.