Teiv
Teiv

Reputation: 2635

How to tell Notepad++ to indent the line exactly like before I press Enter?

I'm using Notepad++ to write PHP and I find the way of not having same indent as before pressing Enter is rather disturbing. Let say I have a block of code like this :

    foreach()
    {
        if()
        {
        }
    }

If I move the pointer to the beginning of if() line, and press Enter, this line will have indentation like foreach() line

    foreach()
    {

    if()
        {
        }
    }

How can I tell Notepad++ to automatically indent code like this?

    foreach()
    {

        if()
        {
        }
    }

Upvotes: 6

Views: 6529

Answers (1)

BoltClock
BoltClock

Reputation: 723729

Press the Home key and the caret will be moved between the last space/tab and the letter i. Now if you hit Enter, a new line is produced with the if statement keeping its indentation level.

If you use the Home key to jump to the start of lines of code, you'll find that it defaults to moving the caret between the last indent whitespace and the first non-whitespace character. Pressing the key again and again toggles it between this position and the very start of the line. It's way more efficient than pointing and clicking the start of the line with the mouse.

Upvotes: 2

Related Questions