Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Make tab key just insert 4 spaces, not insert 4 spaces AND move to the first char on the line

    Help wanted · · · – – – · · ·
    3
    8
    57
    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.
    • VTGroupGitHub
      VTGroupGitHub last edited by

      Is there a way to configure NPP to make the tab key only insert 4 spaces? Right now, it inserts 4 spaces and then moves the cursor to the first character on the line. Other editors I’ve used like Textpad work the first way, and I find it more useful.

      Alan Kilborn 1 Reply Last reply Reply Quote 0
      • Alan Kilborn
        Alan Kilborn @VTGroupGitHub last edited by

        @VTGroupGitHub

        So for example, your caret is in column 1 on say, an empty line. You press the Tab key, 4 spaces are inserted and your caret moves beyond the spaces and into column 5. You would rather have the caret remain in column 1. Then if you repeatedly press Tab, you’d continue to get groups of 4 spaces inserted, and your caret would still remain in column 1.

        How about a video of Textpad doing this?

        1 Reply Last reply Reply Quote 1
        • VTGroupGitHub
          VTGroupGitHub last edited by

          Let me see if I can describe in words.

          1 - Assume I have a line with 8 spaces followed by some text starting at column 9. The cursor is at the head of the line.

          2 - In both editors, when I press Tab, four spaces are inserted at the beginning of the line, and the text indents so it’s now starting at column 13.

          3 - In Textpad, however, the cursor moves to the end of the newly inserted spaces (i.e. the head of column 5), whereas in NPP, the cursor moves to the text (i.e. the head of column 13).

          I’d like the cursor to continue to stay at the end of the newly inserted spaces, and not jump to the beginning of the text.

          Alan Kilborn 1 Reply Last reply Reply Quote 2
          • Alan Kilborn
            Alan Kilborn @VTGroupGitHub last edited by

            @VTGroupGitHub

            That’s a very much better description.
            I don’t think there’s a native way to make it do that.
            It does the same thing in the Scintilla demo editor.
            Scintilla is the editing component that Notepad++ embeds.
            It could be a setting in Scintilla that I just don’t know about…

            Michael Vincent 1 Reply Last reply Reply Quote 0
            • VTGroupGitHub
              VTGroupGitHub last edited by

              Thank you for confirming. I just wanted to make sure I wasn’t missing something.

              Michael Vincent 1 Reply Last reply Reply Quote 0
              • Michael Vincent
                Michael Vincent @Alan Kilborn last edited by

                @Alan-Kilborn said in Make tab key just insert 4 spaces, not insert 4 spaces AND move to the first char on the line:

                It could be a setting in Scintilla that I just don’t know about…

                Agree the new explanation is much clearer and the setting seems to be:

                SCI_SETTABINDENTS = 0

                By default, N++ has it set to 1. In NppExec, I query it (SCI_GETTABINDENTS ) and it returns 1, but when I set it to 0 and perform the 8 spaces, character at column 9 test described above, I get a tab inserted and my cursor sits at column 4|5.

                SCI_SENDMSG SCI_GETTABINDENTS 
                ================ READY ================
                ECHO $(MSG_RESULT)
                1
                ================ READY ================
                SCI_SENDMSG SCI_SETTABINDENTS 0
                ================ READY ================
                SCI_SENDMSG SCI_GETTABINDENTS
                ================ READY ================
                ECHO $(MSG_RESULT)
                0
                

                Now, assuming the pipe “|” is my cursor:

                |        there are 8 spaces before "there"
                

                Press Tab:

                    |        there are 8 spaces before "there"
                

                So a scripting plugin (NppExec, PythonScript, “PerlScript”) could probably do this for you on startup.

                Cheers.

                1 Reply Last reply Reply Quote 3
                • Michael Vincent
                  Michael Vincent @VTGroupGitHub last edited by

                  @VTGroupGitHub
                  Sorry, forgot to “@” reference you in my previous reply. Also note Scintilla has the “opposite” behavior for going backwards. That is, when you press backspace it can backspace a single space at a time or backspace an entire tab stop. See the Scintilla Docs for what I mean. I’ve added SCI_SETBACKSPACEUNINDENTS in my NppExec startup.

                  Cheers.

                  1 Reply Last reply Reply Quote 3
                  • VTGroupGitHub
                    VTGroupGitHub last edited by

                    I hope it’s not too late to say thank you, but I just found your answer to my problem after over a year. Testing with the Console shows your solutions works perfectly, so I’ll set it up now to execute on startup. Thanks!

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post
                    Copyright © 2014 NodeBB Forums | Contributors