Rectangle 27 20

I had to go to Plugins > Plugin Manager > Show Plugin Manager, then install NppAutoIndent from the "Available" tab of that menu (The online download of the plugin wouldn't work). Once installed, go to Plugins > NppAutoIndent, then check "Ignore Language" and "Previous Line".

I'm getting the same indent but with tabs instead of spaces. This is infuriating with python. How can something so simple be done so badly.

this presumes that you have the NppAutoIndent plugin enabled ... Mine was not enabled, BUT I was still getting some auto-indenting ... which means that there exists some other feature within Npp that is also governing auto-indenting.

indentation - Notepad++: disable auto-indent after empty lines - Stack...

notepad++ indentation auto-indent
Rectangle 27 4

In the 6.6.8 version I installed the NppAutoIndent plugin from Plugins > Plugin Manager > Show Plugin Manager. Then I selected the Smart Indent option in Plugin > NppAutoIndent. Hope this helps.

indentation - Auto-indent in Notepad++ - Stack Overflow

notepad++ indentation code-formatting
Rectangle 27 12

I can confirm that this issue happens with Notepad++ version 5.0.3. The only related setting I have found is under Settings > Preferences > MISC > Auto-Indent, but that just turns all auto-indenting on or off.

I have used Editra (http://editra.org) in the past and was happy with it and it appears to handle indenting the way you are describing.

I'm writing prose at the moment and this exactly what I needed cheers!

indentation - Notepad++: disable auto-indent after empty lines - Stack...

notepad++ indentation auto-indent
Rectangle 27 4

I came across this question looking for something similar (working on multiple projects with different indentation styles), and thought I'd provide an answer for anyone else stumbling across this.

There's a nice plugin which makes Notepad++ keep indentation without doing any conversion, "TabIndentSpaceAlign": http://code.google.com/p/kereds-notepad-plus-plus-plugins/

Also available from the Notepad++ Plugin manager. Don't forget to enable the plugin after installing it! (see Plugins menu)

indentation - Notepad++ keeping spaces in indent - Stack Overflow

notepad++ indentation
Rectangle 27 127

Notepad++ will only auto-insert subsequent indents if you manually indent the first line in a block; otherwise you can re-indent your code after the fact using TextFX > TextFX Edit > Reindent C++ code.

If your version is missing the DLL you can get it from the ZIP 5.9.0 version. Some of the later versions did not include this DLL. notepad-plus-plus.org/download/v5.9.0.html

I actually found this while looking for a way to format javascript code. Turns out, this works for .js files as well!

@Fostah: you can also install the "Text FX Character" via >Plugins>Plugin Manager>Show Plugin Manager

TextFX > TextFX Edit > Reindent

indentation - Auto-indent in Notepad++ - Stack Overflow

notepad++ indentation code-formatting
Rectangle 27 77

There is no universal tab size, so I always make sure to replace tabs by spaces (so you know what you see is what you get everywhere else as well)

Go to Settings -> "Preferences..." -> Language Menu/Tab Settings and check 'Replace by space'

oh yeah, I forgot to mention that too. One too many times I've got bitten by using the tab. :)

Oh, sweet..didn't know that was possible. Thanks!

+1 This is exactly what I do before I spend serious development time on any IDE.

You can make this change for Python only if you select Go to Preferences -> Language Menu/Tab Settings -> <Select Python from the list> and check 'Replace by space'

Tab is usually 4 spaces by convention. I guess this is intuitive. But in real world Notepad++ has its own way which pythons seems not to understand. Thanks for the fix. This really helped me.

python - Notepad++ indentation messes up - Stack Overflow

python notepad++ indentation
Rectangle 27 76

There is no universal tab size, so I always make sure to replace tabs by spaces (so you know what you see is what you get everywhere else as well)

Go to Settings -> "Preferences..." -> Language Menu/Tab Settings and check 'Replace by space'

oh yeah, I forgot to mention that too. One too many times I've got bitten by using the tab. :)

Oh, sweet..didn't know that was possible. Thanks!

+1 This is exactly what I do before I spend serious development time on any IDE.

You can make this change for Python only if you select Go to Preferences -> Language Menu/Tab Settings -> <Select Python from the list> and check 'Replace by space'

Tab is usually 4 spaces by convention. I guess this is intuitive. But in real world Notepad++ has its own way which pythons seems not to understand. Thanks for the fix. This really helped me.

python - Notepad++ indentation messes up - Stack Overflow

python notepad++ indentation
Rectangle 27 80

If the TextFX menu does not exist, you need to download & install the plugin. Plugins->Plugin Manager->Show Plugin Manager and then check the plugin TextFX Characters. Click 'install,' restart Notepad++.

In version Notepad++ v6.1.3, I resolve with: Plugin Manager->Show Plugin Manager** and then check the plugin "Indent By Fold"

Indent by fold is awesome. The fact that it works in arbitrary formatting (XML, C/++/#, etc.) is great. Only problem with it is the "undo" stack. When used, if you wish to undo to a point before when you indented, you have to undo through every line re-indentation, as it doesn't get added to the stack as a single command. Basically, be careful when working with long files.

Hi @Dan the undo problem seem to have been fixed in newer version of indent by fold...

indentation - Auto-indent in Notepad++ - Stack Overflow

notepad++ indentation code-formatting
Rectangle 27 35

In version 7.2.2, the Tab Settings are under:

Settings > Preferences > Language > Tab Settings

indentation - How I can increase tab width in notepad++ (v6.5)? - Stac...

notepad++ indentation
Rectangle 27 3

Use the macro "Trim Trailing and save" short-cut "Alt + Shift + S"

I you need this all the time, just swap the save short-cut with the macro "Trim Trailing and save" short-cut.

indentation - Notepad++: disable auto-indent after empty lines - Stack...

notepad++ indentation auto-indent
Rectangle 27 28

I would suggest going to View > Show Symbol > Show Whitespace and Tab to get an better idea of how your indentations look.

Under appreciated comment. This allows for instant correction of faulty tabs/spaces in Notepad++. Thank you

python - Notepad++ indentation messes up - Stack Overflow

python notepad++ indentation
Rectangle 27 27

I would suggest going to View > Show Symbol > Show Whitespace and Tab to get an better idea of how your indentations look.

Under appreciated comment. This allows for instant correction of faulty tabs/spaces in Notepad++. Thank you

python - Notepad++ indentation messes up - Stack Overflow

python notepad++ indentation
Rectangle 27 31

TextFX -> TextFX HTML Tidy -> Tidy: reindent XML

indentation - Auto-indent in Notepad++ - Stack Overflow

notepad++ indentation code-formatting
Rectangle 27 2

I am not aware of any setting that would copy the exact indentation style (combination of tabs and spaces) from the previous line. You can chose to convert all tabs to spaces and the number of spaces per tab (tab stops) in the settings dialog but I think that's the limit of your options. It should be possible to develop a plugin to do this afterwards but I'm not aware of a plugin that does this currently.

indentation - Notepad++ keeping spaces in indent - Stack Overflow

notepad++ indentation
Rectangle 27 26

Most developers of text editing programs misuse this name (auto-indent). The correct name is "maintain indentation". Auto-indent is what you actually want, but it is not implemented.

I would also like to see this feature in Notepad++.

indentation - Auto-indent in Notepad++ - Stack Overflow

notepad++ indentation code-formatting
Rectangle 27 2

It is unfortunate that Notepad++ doesn't trim the second empty new line automatically. But, as a work-around, I agree with user108570: a macro would be perfect.

I like to make a conceptual distinction between "soft" versus "hard" linefeeds, analogously to the two types of tabs. The output of the former depends on the current style and indentation settings. The output of the latter, however, should always be a simple, unadulterated, plain vanilla new-line.

The most frequently used flavour of linefeed should, of course, be mapped to the simpler key-combination. For most of your editing you would probably want to leave "soft linefeed" mapped to the "Enter" key and change "Ctrl+Enter" to trigger a "hard linefeed".

In "Menu -> Settings -> Shortcut Mapper -> Main Menu" you will see that by default "Ctrl+Enter" is mapped to "Word Completion". This needs to be disabled first by mapping it to "None".

Then simply record a macro:

The last step will pop a dialog where you would name the macro (e.g. "Hard Linefeed") and set its mapping (i.e. "Ctrl+Enter").

At step 3 we could have added anything (printable). Its sole purpose is to add something to delete if there was nothing before, so that any text following the cursor will remain untouched.

indentation - Notepad++: disable auto-indent after empty lines - Stack...

notepad++ indentation auto-indent
Rectangle 27 20

In the latest version (at least), you can find it through:

  • "Auto-indent" is the 2nd option in this group

[EDIT] Though, I don't think it's had the best implementation of Auto-indent. So, check to make sure you have version 5.1 -- auto-indent got an overhaul recently, so it auto-corrects your indenting.

Do also note that you're missing the block for the 2nd if:

void main(){
  if(){
    if() { }  # here
  }
}

Note that this auto-indent setting in Notepad++ assumes you do the first indent in a block manually; it doesn't auto-format the code for you.

indentation - Auto-indent in Notepad++ - Stack Overflow

notepad++ indentation code-formatting
Rectangle 27 13

You can use 'Indent by fold' plugin. Install it from the plugin manager. It works fine for me.

it does not unintend the closing brace

Indent by fold is great, except that it only indents by fold ;) In situations where you've indented a list initialization, unless the language uses a folding character to delimit the initializer, it'll end up un-indenting. An example is a multi-line array initialization in PHP using array( ... ), where () are non-folding.

indentation - Auto-indent in Notepad++ - Stack Overflow

notepad++ indentation code-formatting
Rectangle 27 10

indeed, I found this option Tidy (most recent HTMLTIDY.CFG), but it appears as gray and I can't click it..

indentation - Auto-indent in Notepad++ - Stack Overflow

notepad++ indentation code-formatting
Rectangle 27 5

Python has a lexer that generates Indent and Dedent tokens, that are equivalent to curly braces ("{", "}"). There is even an example on Stack Overflow, with a simple implementation of such a lexer.

Parsing "off-side" (indentation-based) languages - Stack Overflow

language-design indentation compiler-theory