How can I set Notepad++ to indent with spaces?
Runemoro last edited by
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.
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.
There are at least 3 related fixes that I wanted in this area and implemented for myself.
- New line will be indented according to the indentation style of previous line.
- When a line indent is modified (add/remove tab) the indent will be according to current indent style and not according to global style.
- 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.
Alice Choury last edited by
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 ?
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
Christopher McLaughlin last edited by
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.
not quite sure what you are referring to?
NippurDeLagash last edited by
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.
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.