Community
    • Login

    How to get Notepad++ to automatically indent one tab when hitting enter.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 2 Posters 14.5k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Pete NorrisP Offline
      Pete Norris
      last edited by

      Hello Notepad++ Forum;

      Question: How can I get Notepad++ to indent one tab or two spaces when I hit the enter key?

      Here is how Notepad++ currently does:

      if (in_array($some_value,$some_arr)){
      // no indent
      }

      Here’s what I would like for it to do:

      if (in_array($some_value,$some_arr)){
      // indent one tab or two spaces
      tab}

      Thank you in advance.

      PN

      1 Reply Last reply Reply Quote 0
      • Jim DaileyJ Offline
        Jim Dailey
        last edited by

        Try Settings–>Preferences–>MISC. and check AutoIndent.

        You might want/need to change Tab Settings in the Preferences dialog box.

        1 Reply Last reply Reply Quote 0
        • Pete NorrisP Offline
          Pete Norris
          last edited by

          Jim;

          Thanks for responding to my question. I appreciate the help.

          The AutoIndent was already checked in the Settings–>Preferences–>MISC. dialog box.

          The Settings–>Preferences–>Tab Settings is set at 2 (Default). I can increase it to five and it still won’t indent.

          It looks like it ought to be indenting but it’s not. It could be a bug in the program.

          Are there any other suggestions I might try?

          Thanks.

          PN

          1 Reply Last reply Reply Quote 0
          • Jim DaileyJ Offline
            Jim Dailey
            last edited by

            I believe the functionality you are looking for is controlled by the lexer for the “language” of the file you are editing (e.g. file.c, file.asm, file.cpp).

            It looks like you may be editing PERL. If I edit a .C file, autoindent works as expected, but if I set the Language to PERL, autoindent does not work as I would hope.

            1 Reply Last reply Reply Quote 0
            • Pete NorrisP Offline
              Pete Norris
              last edited by

              Jim;

              I’m using PHP. My initial question was not clear. It’s my fault.

              The first line does indent. It’s the second line I am talking about - the one that has the closing bracket.

              // PERL does like this:
              if ($one == NULL){
              }

              // C and PHP both do like this:
              if ($one == NULL){
              –>one tab indent
              } bracket does not indent

              // I’ve been using UltraEdit for 15+ years. It does like this:
              if ($one == NULL){
              –>} bracket one tab indent

              // I’m trying to get Notepad++ to do like this:
              if ($one == NULL){
              –>one bracket first line indent
              –>} bracket one tab indent

              I became accustomed to indenting the bracket one tab or two spaces with UltraEdit.

              The last two upgrades of UltraEdit did not work right for me. That’s when I started using Notepad++.

              Notepad++ is a really nice program. It’s had a lot of thought and hard work go into it.

              1 Reply Last reply Reply Quote 0
              • Jim DaileyJ Offline
                Jim Dailey
                last edited by

                @Pete-Norris I see. I’m pretty certain the lexer for the language (PHP in your case) controls the auto-indent behavior. I don’t think there is any way at run-time to modify its behavior. I assume you’d have to edit the lexer to make it behave differently and then build a custom NPP.

                I am not aware of any, but there may be a plug-in for NPP you could find that handles indentation in some other way.

                Sorry I have no better ideas.

                1 Reply Last reply Reply Quote 0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors