7

When pressing enter in Notepad++ to create a new line, is it possible to obtain the exact indentation of the previous line for the new line? No matter what I've tried, Notepad++ will always replace as many spaces as possible with tabs.

As an example, say I have the following (---> is a tab, . is a space, | is the cursor):

--->--->a_very_long_variable_name = another_long_name
--->--->..........................+ yet_another_variable|;

Lets say I want to add a third operand on a new line. After pressing Enter, I would expect the following:

--->--->a_very_long_variable_name = another_long_name
--->--->..........................+ yet_another_variable
--->--->..........................|;

Unfortunately, what Notepad++ actually produces is this:

--->--->a_very_long_variable_name = another_long_name
--->--->..........................+ yet_another_variable
--->--->--->--->--->--->--->--->..|;

Does anyone know of a setting or plugin that can be used to get an exact copy of the indentation, rather than replacing spaces by tabs?

It would also be nice if block indenting/unindenting would only affect the number of leading tabs, rather than again changing spaces to tabs.

3
  • Why do you want to mix spaces and tabs like that? Commented Dec 21, 2012 at 0:15
  • 1
    @ellak We follow the principle that tabs are used for indentation, and spaces are used for alignment. This allows everyone to choose an indentation size they like, without running into misalignment issues when different people use different indentation sizes. The front two tabs are indentation, the spaces are alignment. Commented Dec 21, 2012 at 8:06
  • Check this answer here, maybe it will help: stackoverflow.com/a/8197841/3437245 Commented Jun 15, 2018 at 6:50

2 Answers 2

5

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)

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.