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



  • 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.



  • @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?



  • 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.



  • @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…



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



  • @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.



  • @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.


Log in to reply