Focus on opened file



  • Closing n++ with a sidebar active like workspace/docswitcher or the character panel for instance, has a bit of an annoying side-effect, next time you open a file (and I usually do that with shortcut-keys/typing only) the focus automatically goes to one of the sidebars, instead of the just opened file a tab.
    I’m usually already typing away or hitting pgdn or something (and yes I fall for this time and time again hehe) to only notice the character panel scrolling down.

    I’m not using n++ that long yet, so I might not know every hidden setting yet, but I browsed the xml’s, the settings… but can’t really find a setting which let’s me alter this behavior. Is it possible using a setting ? Or do I need to find a different solution ? Plugin ?



  • @Harold-Coenen

    Depending upon the lengths you want to go to…the following is semi-related and worked for me: https://notepad-plus-plus.org/community/topic/12467/keystroke-to-switch-focus-from-console-window-to-active-editor-tab/5



  • Perfect solution ! Didn’t have the python-script plugin installed yet, but already noticed it will most definitely come in handy for all sorts of quick and dirty tricks/automation :-)

    By the way: why SendKeys.SendKeys("%{W}W{ENTER}") and not just SendKeys.SendKeys("{F8}") ? That is, if you like the SendKeys import and method… the editor.grabFocus() as last line in the startup.py is my preferred solution - no extra import and no faking key-presses, yet still 100% fail-proof focus to main edit window (with init set to ATSTARTUP in the python script configuration of course).

    Thank you for the great tip ! I didn’t look hard at existing plugins… will try some others too :-)



  • @Harold-Coenen

    Regarding “why not use SendKeys(”{F8}") or editor.grabFocus() in startup.py"?

    Because neither of those things worked (for me, at least) that way. Just checked again, and they still don’t work. :-)



  • Good enough reason /me thinks ;-) lol


Log in to reply