File type dependent "Trim trailing spaces"

File type dependent "Trim trailing spaces"

2
NewbieNewbie
2

    May 22, 2015#1

    I'm surprised by all the features UltraEdit provides (using UEStudio 14). It's overwhelming. Unfortunately I run against walls finding the simple things everyone needs first in an editor.

    For example, where can I configure file type depending settings for the "Trim trailing spaces" command. I find global settings but fail locating file type specific settings. Can somebody help?

    Thank you.

    6,603548
    Grand MasterGrand Master
    6,603548

      May 23, 2015#2

      The reason for not finding a file type dependent Trim trailing spaces on file save configuration setting is simply there is none, whether in currently latest UltraEdit v22.0.0.66 nor in currently latest UEStudio v15.10.0.11, just the global setting for all files. The only configuration settings which can be set depending on file type (file extension) are those at Advanced - Configuration - Word Wrap/Tab Settings.

      I can offer following solution to get a file extension based trim trailing spaces on file save:
      1. Uncheck Trim trailing spaces on file save in configuration.
      2. If there is currently a macro file loaded, unload all macros using Macro - Delete All.
      3. Open Macro - Edit Macro.
      4. Click on button New macro.
      5. Enter a macro name like Save Trim Spaces, uncheck both macro properties, and click on button OK.
      6. Select all existing lines in edit macro dialog and delete them with key DEL.
      7. Insert the following lines (example):

        Code: Select all

        IfExtIs "c"
        TrimTrailingSpaces 
        ExitMacro
        EndIf
        IfExtIs "cpp"
        TrimTrailingSpaces 
        ExitMacro
        EndIf
        IfExtIs "h"
        TrimTrailingSpaces 
        ExitMacro
        EndIf
        The file extension comparison is done by UE/UES case-insensitive. So it does not matter if file extension strings are defined in the macro in lower case or in upper case.
      8. Close the edit macro dialog with clicking on button Close and confirm updating just created macro with Yes.
      9. Use Macro - Save All to save this macro into a file for example with name LoadSaveMacrosUES.mac wherever you want.
      10. Open Macro - Set Macro for File Load/Save.
      11. Browse to and select the macro file LoadSaveMacrosUES.mac just saved.
      12. Enter for Save Trim Spaces for Macro name to run on save and set 1 for # of times.
      13. Click on button OK.
      That's it. The trailing spaces and tabs are now removed on each file save for the files with a file extension defined in the macro.
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        May 23, 2015#3

        Wow,Mofi. I'm impressed. Thank you very much.