In notepad++ change tab size instantly

喜夏-厌秋 提交于 2019-11-28 02:10:27

Ok, there's an easy way how you can achieve this - I have tested it right now:

  1. Install AutoHotKey (or start portable version which runs without installation)
  2. 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
  3. Right click Autohotkey tray icon and select Edit This Script
  4. Import the macro below this list at the end of the AutoHotKey script file and save the file
  5. Right click Autohotkey tray icon and select Reload This Script.
    –– This was end of general steps, now let's go with your macro: ––

  6. In N++, display Preferences window and press its Close button1 at the bottom (NOT at the top-right corner)

  7. 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!
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!