Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

tabs

notepad++

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()
        {
        }
    }
like image 206
Teiv Avatar asked Nov 06 '22 01:11

Teiv


1 Answers

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.

like image 55
BoltClock Avatar answered Nov 14 '22 15:11

BoltClock