Ok, there's an easy way how you can achieve this - I have tested it right now:
- Install AutoHotKey (or start portable version which runs without installation)
- In Windows 7 and above, ensure you launched AutoHotKey as Administrator (otherwise you get inconsistencies in its behavior) - if not sure, exit it and restart it as administrator
- Right click Autohotkey tray icon and select
Edit This Script
- Import the macro below this list at the end of the AutoHotKey script file and save the file
Right click Autohotkey tray icon and select Reload This Script
.
–– This was end of general steps, now let's go with your macro: ––
In N++, display Preferences
window and press its Close button1 at the bottom (NOT at the top-right corner)
Now you can use shortcuts Win+F2 and Win+F3 to switch different tab sizes instantly
SendMode Input
DetectHiddenWindows, On
SetTitleMatchMode, RegEx
;--------------------------------- Hotkeys for Notepad++ only
#IfWinActive ahk_class Notepad\+\+
#F2::Send {F10}{Right 6}{Down}{Enter}{Tab 2}{Space}16{Enter}{Tab 3}{Space}
#F3::Send {F10}{Right 6}{Down}{Enter}{Tab 2}{Space}4{Enter}{Tab 3}{Space}
#IfWinActive
1) Important: N++ user experience provided in dialog boxes is absolutely terrible. There are no anchors where you can fix focus when using keyboard. Thus you always need to perform step 4
manually when leaving Preferences
dialog box otherwise the macros would send keys into incorect window page OR at correct page but incorrect control. Preferences
dialog window remembers selected page and control. Macros I created for you therefore assume that correct page is already listed and button Close was recently focused.
Good news is Notepad++ windows with this weird behavior are rare exception from general user experience. In other places in N++ (or in other apps) where user interface components (menus, dialogs etc.) always start from the same point you do not need any special precautions like the one in step 4.
Adjust the macros as you like:
- you can create more of them
- you can adjust the numbers "16" and "4" typed into tab size input box
- you can change shortcut keys to something else
- you can replace sending keys with sending mouse clicks at desired screen/window positions
- you can achieve many other useful shortcuts in N++ and in all other apps – check AHK deeper!
Preferences -> TabSettings -> TabSize
and the value is kept set correctly even if I restart N++. – Customary