Way to make Notepad++ auto-complete words on {TAB} instead of {ENTER}

autocompletekeyboard shortcutsnotepadplugins

Is there a way to make Notepad++ auto-complete words on Tab instead of Enter?

Currently, if want to type, say, frame, then Enter to begin a new line, instead the Enter will select the first auto-complete suggestion, like frameElement:

    enter image description here

I do want the auto-complete feature, but I'd rather have a key like Tab do the actual selection, because Enter is frequently purposed toward starting a new line, whereas Tab is rarely used to indent after a word (since indenting is usually done at the start of lines), and so perhaps would be better repurposed toward auto-completion.

Best Answer

This undesired behavior is hard-coded into Scintilla, the text editing component that underlies Notepad++. It can be fixed by removing the following three lines from src/ScintillaBase.cxx:

        case SCI_NEWLINE:
            AutoCompleteCompleted(0, SC_AC_NEWLINE);
            return 0;

With this change, the Enter key no longer commits autocompletion. The Tab key already does that, as noted by user2427906.

It should be possible to download the source code for Notepad++ (which includes Scintilla), make the above change in scintilla\src\ScintillaBase.cxx (the code is slightly different in Notepad++ 6.9, but this shouldn’t be a problem), and then build Notepad++ from the modified source code.

I haven’t tried this because I don’t use Notepad++ nor Windows, but I did the same to Geany—another text editor based on Scintilla—and it seems to work.

Related Question