Is there a way to make Notepad++ auto-complete words on {TAB} instead of {ENTER}?

5,018

Solution 1

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.

Solution 2

Version 8.2.1 allows choosing any combination of tab and enter:

Notepad++ auto-complete settings

Solution 3

The settings for both Tab and Enter are in the Shortcut mapper on the Settings menu. See the Scintilla Commands tab.

However, you cannot change the Tab entry to Enter as Enter is already mapped.

As intimated, this is a function of the embedded Scintilla component not the fault of Notepad++ itself.

enter image description here

enter image description here

Solution 4

In the new version, there is no more appropriate to change the keyboard shortcut.
The effect of Tab is same as than Enter.

I am using notepad++ 6.7.3

Share:
5,018

Related videos on Youtube

Andrew Cheong
Author by

Andrew Cheong

Early web dev (1999 to around when jQuery came out), a decade of C++ in stock exchanges, and now Java in ad tech. Here, I used to go by A—— C——, farmed XP on the regex tag to wield fake authority on unrelated subjects, ♦'ed a beta site, and created the SOCVR chatroom. (I take no credit for the community it's grown into today, that was @rene et al.)

Updated on September 18, 2022

Comments

  • Andrew Cheong
    Andrew Cheong over 1 year

    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.

  • Jon
    Jon almost 10 years
    What is the name of the shortcut mapping? I don't see it anywhere.
  • Julian Knight
    Julian Knight almost 10 years
    I've added appropriate screenshots
  • Jon
    Jon almost 10 years
    Yeah, but which specific one is it? There's ~40 of them and I don't see it.
  • Julian Knight
    Julian Knight almost 10 years
    Tab is 10 and Enter is 9
  • Deqing
    Deqing almost 8 years
    It works for me, I'm using 6.8.6
  • Deqing
    Deqing almost 8 years
    Finally found out how to do it: remove "Enter" in SCI_NEWLINE
  • TigerhawkT3
    TigerhawkT3 over 5 years
    There are two components to this problem: the Enter hotkey triggers SCI_NEWLINE, and SCI_NEWLINE commits autocompletion. The accepted answer deals with the latter, while this answer deals with the former. Changing the hotkey for SCI_NEWLINE is a simple change in a menu (I rebound it to Alt-Enter), while preventing SCI_NEWLINE from committing autocompletion requires editing and rebuilding the whole program from source (every time you want to change this). This answer is far superior.
  • AXO
    AXO about 4 years
    After this change pressing the enter key types a CR instead of LF. Also the auto-indentation feature no longer works.
  • Julian Knight
    Julian Knight about 4 years
    @AXO, thanks for the update. Please note that this answer was from 4 1/2 years ago and likely much has changed since then. The accepted answer was from nearly 2 years later - go figure! :-)
  • Blaisem
    Blaisem about 3 years
    @TigerhawkT3 The problem with this solution is that SCI_NEWLINE preserves indentation. If you are typing code or notes on the 2nd or 3rd indentation, it's highly convenient when you can press enter, and the next line begins on that tier and maintains your organization. This use-case occurs more often than the last word of a line being autocompleted because of a mistake with enter, so this solution isn't actually good right now.
  • TigerhawkT3
    TigerhawkT3 about 3 years
    @Blaisem - Yeah, I think I ended up changing it back and just dealing with the annoyance of double-pressing Enter, or pressing Esc to dismiss the autocomplete (when a longer word is suggested) and then pressing Enter. Given that there's almost no reason to press Tab other than leading whitespace and lots of reason to press Enter after typing stuff, it makes no sense that autocomplete is bound to both rather than just to Tab. I guess it'd be a moot point for a language like C where every line ends with punctuation anyway, but for Python it's one of my biggest Notepad++ gripes.
  • Blaisem
    Blaisem about 3 years
    @TigerhawkT3 There are some feature requests for this on the GitHub forum with one commenter actually having posted a viable workaround in 2018 (he adds an option to turn off newline with autocompletion in the preferences). For now, I am going to turn autocomplete off.