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

5

3

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.

Andrew Cheong

Posted 2014-06-09T18:47:48.120

Reputation: 1 355

Answers

4

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.

Vasiliy Faronov

Posted 2014-06-09T18:47:48.120

Reputation: 156

4

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

Julian Knight

Posted 2014-06-09T18:47:48.120

Reputation: 13 389

1Finally found out how to do it: remove "Enter" in SCI_NEWLINE – Deqing – 2016-06-14T05:34:18.707

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.

– TigerhawkT3 – 2019-01-15T23:35:19.073

After this change pressing the enter key types a CR instead of LF. Also the auto-indentation feature no longer works. – AXO – 2020-02-20T13:40:09.823

@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! :-) – Julian Knight – 2020-02-21T17:42:20.823

What is the name of the shortcut mapping? I don't see it anywhere. – Jon – 2014-06-13T20:59:43.080

I've added appropriate screenshots – Julian Knight – 2014-06-13T21:07:55.890

Yeah, but which specific one is it? There's ~40 of them and I don't see it. – Jon – 2014-06-13T21:16:49.587

1Tab is 10 and Enter is 9 – Julian Knight – 2014-06-13T21:23:41.507

1

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

user2427906

Posted 2014-06-09T18:47:48.120

Reputation: 31

It works for me, I'm using 6.8.6 – Deqing – 2016-06-14T05:33:19.130