Keystroke to switch focus from console window to active editor tab?

  • Is there a keystroke to switch focus from the plugins with “console” windows back to the active editor tab? I’m speaking of either the Pythonscript or the NppExec plugin consoles–I can switch back with the mouse, but doing that results in the current caret position being changed, or selections that are active disappearing, neither of which is desirable.

    The functionality I’m looking for is similar to the F7 key (default) when using the Find Result panel–if your focus is in that panel, pressing F7 will get you back to the active editor window, caret-position unmoved, and selection blocks still highlighted.

  • AFAIK there isn’t anything built in. However you can do it from PythonScript (which you can tie to a shortcut). You’d have to do:


    See the documentation for grabFocus().

  • Hi Scott,

    Humm… I just tried and…( I may be wrong ) I’m thinking about a very easy way to do it :-))

    So, let’s suppose you opened our loved editor and that you displayed, for instance, the Python Console. Then :

    • With your mouse, create, in the current file, a normal or column mode selection ( or even the two ones, simultaneously ! )

    • Click inside the Python console to get the focus on the plugin

    • Right-click, on the tab of the current file, to get the specific context menu, about tabs

    • Finally, either, hit the ESC key OR Left-click on the current tab, to close the context menu

    => The focus should be back to the main editor window, with all the selections still highlighted and the cursor location unchanged



  • @dail

    Thanks for the reply. It doesn’t seem to get invoked when my focus is anywhere in the Pythonscript console window and I press the keycombo I’ve assigned. If I’m in an editor window and press the keycombo, I see the console write of the debug message (“I’m running”) I created to make sure nothing else is breaking down with my process. However, when I’m in the console area, pressing the keycombo results in no debug message. Same bad result if the NppExec console window has focus when invoked. It DOES work if I’m in the Find Result panel when I run it, or if I run it via the menu after giving focus to either of the mentioned consoles…

  • @Scott-Sumner Ah ok. I remember doing something similar before but my use-case was a bit different.

  • @Scott-Sumner

    Hi Scott, nppexec has a builtin function “toggle console dialog” and for python script
    and others I do alt+w+w+enter.


  • I was hoping for a single keystroke to achieve it, but the solutions provided by Claudia and guy038 do indeed achieve the goal. Thanks to all for the help.

  • Hi @Scott-Sumner ,

    If you are using NppGTags plugin then you can use its “Toggle Results Window Focus” command to switch to your active Scintilla doc window. You’ll need to assign a shortcut to the plugin command to be able to use it without the mouse.
    However it will just take you to the edited document - there is currently no way to switch the focus back to PythonScript or NppExec console.
    I can easily implement it though.


  • I noticed that when Notepad++ starts up (with Pythonscript plug-in installed), after everything initializes, the input focus is left on the Pythonscript console window because I use a “” in my script. This is less than desirable, so I added the following further down in my, based upon Claudia’s tip above:

    import SendKeys
    SendKeys.SendKeys("%{W}W{ENTER}")  # press Alt+W, then W, then Enter (to give focus to the editing tab that was active in the previous N++ run)

  • A slightly faster solution than @Claudia-Frank 's alt+w+w+enter is the double Windows logo press suggested by @guy038 in this thread:

  • Hi Scott,

    A slightly faster solution than @Claudia-Frank 's alt+w+w+enter is the double Windows logo press

    but this doesn’t work on my linux installation :-(


  • Another way to achieve the original goal of this thread (moving input focus) was inadvertently pointed out in this thread. Thus:

    Enable (tick) the Peek on tab feature in the MISC. section (of Settings menu -> Preferences). When your input focus is NOT in your active document (maybe it is in a console window or the Find-what zone of the Find window), but you want to move it there without changing caret position or destroying a currently-active selection(s), simply point the mouse at an inactive tab–assumes you have more than one file open–and the (IMO otherwise useless) document-peeker window will pop up. You will find input focus is now back in the editing window for the currently-active tab in the most recently-accessed view (view0 or view1).

Log in to reply