Ctrl+Tab as a macro command & keyboard command

Ctrl+Tab as a macro command & keyboard command

6
NewbieNewbie
6

    Jan 04, 2021#1

    The Ctrl+Tab feature is handy, allowing quick switching between two documents.

    Surprisingly, the Ctrl+Tab is not listed in the Help under Keyboard Commands nor is it available as a macro command.

    Why?

    With many documents open, it will switch back & forth between ONLY two of them.
    I was hoping to find a macro command that would do this.
    Neither NextDocument/PreviousDocument nor NextWindow/PreviousWindow do this.

    6,675585
    Grand MasterGrand Master
    6,675585

      Jan 05, 2021#2

      Please post which version of UltraEdit for Windows is used by you at the moment. The Ctrl+Tab and Ctrl+Shift+Tab behavior changed in the past as it can be read in the thirty posts of forum topic Navigation between different file tabs. The last modification of Ctrl+Tab and Ctrl+Shift+Tab was with UltraEdit for Windows v26.00 documented in file changes.txt in program files folder of UltraEdit with:

      Code: Select all

      - Modernized Key mapping
           * Re-map Ctrl + Tab and Ctrl + Shift + Tab (provides browser-like tab switching behavior)
      
      Ctrl+Tab and Ctrl+Shift+Tab are not documented on help page Keyboard Commands and also not listed in the text file created on pressing on button Show key mapping in editor at Advanced - Settings or Configuration - Key mapping as the behavior is smart coded now. There is no single command for Ctrl+Tab.

      The explanation below is for UltraEdit for Windows v26.00 and later versions.

      Pressing once Ctrl+Tab with leaving both keys results in using more or less the command Next window which is as macro command NextWindow. Doing this results in changing the last access file windows list. So on pressing once again Ctrl+Tab with leaving both keys the previous window is again made the active window and the last access file windows list is updated once again. I recommend to do following to better understand here what happens on pressing Ctrl+Tab:
      1. Close all opened files and then open four files at once in UltraEdit, for example C:\Temp\FileA.txt, C:\Temp\FileB.txt, C:\Temp\FileC.txt and C:\Temp\FileD.txt by using File - Open executed with Ctrl+O. Select first FileD.txt with left mouse button, then press and hold key Shift and click with left mouse button on FileA.txt, leave key Shift and click on button Open or press key RETURN.
      2. Now right click on a ribbon tab and left click in opened context menu in submenu Toolbar/menu mode on either Contemporary menus or Traditional menus. Don't worry if you favor the ribbon mode. You can later right click on menu bar and left click on Ribbon mode to switch back to this user interface mode. But for understanding what is going on a menu mode with menu Window is essential.
      3. The file tabs show now FileA.txt, FileB.txt, FileC.txt and FileD.txt with FileD.txt being the active file.
        Click now on menu Window. There can be seen at bottom the windows of the files in last access order which is:
        1. C:\Temp\FileD.txt
        2. C:\Temp\FileC.txt
        3. C:\Temp\FileB.txt
        4. C:\Temp\FileA.txt
      4. Then click with left mouse button on file tab FileB.txt and open once again the menu Window.
        There can be seen now at bottom:
        1. C:\Temp\FileB.txt
        2. C:\Temp\FileD.txt
        3. C:\Temp\FileC.txt
        4. C:\Temp\FileA.txt
      5. Press Ctrl+Tab and leave both keys. There is selected the file tab FileD.txt.
        Open once again the menu Window and look on the list of file windows at bottom which is now:
        1. C:\Temp\FileD.txt
        2. C:\Temp\FileB.txt
        3. C:\Temp\FileC.txt
        4. C:\Temp\FileA.txt
      6. Press once again Ctrl+Tab and leave both keys. There is once more selected the file FileB.txt.
        Open once again the menu Window and look on the list of file windows at bottom which is now:
        1. C:\Temp\FileB.txt
        2. C:\Temp\FileD.txt
        3. C:\Temp\FileC.txt
        4. C:\Temp\FileA.txt
      I hope, everything described up to now is clear so far. Ctrl+Tab toggles the first two items in last access file windows list.

      But what does happen on using a macro containing just the macro command NextWindow or using the command Next window with its hotkey Ctrl+F6 or from menu Window?
      1. Press Ctrl+F6 and selected is once again FileD.txt as being the second item in the list.
        The menu Window lists the file windows as expected:
        1. C:\Temp\FileD.txt
        2. C:\Temp\FileB.txt
        3. C:\Temp\FileC.txt
        4. C:\Temp\FileA.txt
      2. Press next once again Ctrl+F6 and selected is FileC.txt and not FileB.txt as being the next file in last access file windows list.
        The menu Window lists now:
        1. C:\Temp\FileC.txt
        2. C:\Temp\FileD.txt
        3. C:\Temp\FileB.txt
        4. C:\Temp\FileA.txt
      Why this difference? Why is FileC.txt and not FileB.txt selected by using command Next window?

      Well, the reason is pretty simple. If the command Next window would always select the next file window according to last access list, it would be impossible to use this command to select ever any other file than the last two accessed files like on using all the time always just Ctrl+Tab with leaving both keys. That is not good for users which would like the keyboard to switch between the opened files by pressing Ctrl+F6 multiple times. That is also the reason why pressing Ctrl+F6 a third time results in selecting next FileA.txt. The command Next window prevents selecting a file window which was selected already before in a series of Next window executions. There is an internal, not visible access file window list used by Next window which prevents selecting a file which was selected with command Next window before until each file was selected at least once in the rotation.

      The behavior of the commands Next file tab with hotkey Alt+DOWN ARROW and Previous file tab with hotkey Alt+UP ARROW are much easier to understand as the order of the selected file window is always according to the file tabs order of the windows. The last access order of the file windows does not matter for these two commands.

      What happens on pressing Ctrl+Tab multiple times with holding key Ctrl between each pressing of key Tab?

      Let us look on this file selecting behavior again with an example:
      1. Click with left mouse button on the file tabs in following order: FileA.txt, FileB.txt, FileC.txt, FileD.txt.
        The Window menu lists the file windows now:
        1. C:\Temp\FileD.txt
        2. C:\Temp\FileC.txt
        3. C:\Temp\FileB.txt
        4. C:\Temp\FileA.txt
      2. Press key Ctrl, hold it and press Tab, but continue holding key Ctrl. The file FileC.txt is selected which is expected as it is the second item in last access list.
      3. But the key Ctrl is still hold. For that reason the last access file windows list is not updated intentionally.
        Press next Tab while Ctrl is still hold and the third file in last access file windows list is selected which is FileB.txt.
      4. While the key Ctrl is still hold press once again on Tab and this time leave also key Ctrl. The file FileA.txt is selected as expected.
        The Window menu lists the file windows now:
        1. C:\Temp\FileA.txt
        2. C:\Temp\FileD.txt
        3. C:\Temp\FileC.txt
        4. C:\Temp\FileB.txt
      The temporary selection of FileC.txt and FileB.txt has not resulted in an update of the last access file windows list. The key Ctrl must be left to update the list.

      Ctrl+Shift+Tab results in execution of Previous window with the extra coded behavior of not updating the last access file windows list as long as Ctrl is hold. It is not possible with Ctrl+Shift+Tab to switch permanently between the same two file windows. That is easy to see on looking on the list in menu Windows. The entire list changes on using Ctrl+Shift+Tab, not just the first two items like on using only Ctrl+Tab.

      How to toggle on macro execution between active file window on starting the macro and the next active window according to last access file windows list ("previous active" file window) as shown in menu Window without a command emulating Ctrl+Tab behavior?

      Well, the solution is quite simple. The first execution of macro command NextWindow results in selecting the second item in the Window list which is the file which was previously the active file before making the file active on which the macro was started. Then the macro must use the command PreviousWindow to make active again the window of the file which was active on starting the macro.

      So a macro must use alternately the commands NextWindow for selecting the file which was the active file before the file became active on starting the macro and PreviousWindow to select again the active file on starting the macro execution. I know that reads difficult, but it isn´t on using during macro recording Ctrl+F6 and Ctrl+Shift+F6 to toggle between the last two accessed files which results in recording the commands NextWindow and PreviousWindow accordingly.

      Pressing Ctrl+Tab results in no command recorded as there is not really a command available for the special behavior implemented most likely (I can only suppose that) with extra code in program code of UltraEdit on pressing Ctrl+Tab and leaving both keys.

      I wrote many macros more than 10 years ago using in a loop NextWindow and PreviousWindow to switch between two opened files and many of them are even posted in the macros forum. Later I learned that switching often between two file windows during a macro execution increases dramatically the time required to finish the macro execution because of the very time consuming window updates. So I used wherever possible a method to get the lines of one file (list file) copied and pasted into the file to modify at top and used that pasted lines at top to update the lines of the file to modify below mainly with running find+replace all commands. That was already better, but resulted often still in lots of updates of active file window and of course in a massive undo history.

      The usage of an UltraEdit script is nowadays preferred for a task on which two or more files are involved. It is possible with an UltraEdit script to modify the contents of any opened file according to file tab order (last access order is not available in UltraEdit script environment) without making it active. It is very efficient with maximized file windows if on execution of a script one or more files are modified with none of the modified files being the active file.

      I wrote UltraEdit  scripts which just open at script start a new file and closes on script end the newly created file without saving it to be able to modify files without any file window update as the window of the new file never modified during script execution is the only visible file window.

      For small files with less than some MB it is even possible to load all lines of a file into memory of script interpreter, process them there using only JavaScript core methods and then finally output the completely reformatted file contents at once into the file. The main advantage on using this enhanced file update method using a script is that just one undo step is recorded by UltraEdit as the entire file contents is updated with one write or paste command. That decreases the time required to do a file reformat to a minimum and just one Ctrl+Z must be used to restore the file contents before execution of the script on output is not as expected.
      Best regards from an UC/UE/UES for Windows user from Austria

      6
      NewbieNewbie
      6

        Jan 05, 2021#3

        Thanks! Appreciate the details.