UE/UES configuration to edit batch files (*.bat, *.cmd) by default with OEM character set

UE/UES configuration to edit batch files (*.bat, *.cmd) by default with OEM character set

6,603548
Grand MasterGrand Master
6,603548

    Aug 01, 2016#1

    File extension based settings for batch files

    There are just a few steps necessary to configure UltraEdit or UEStudio to edit batch files with file extension BAT or CMD by default with OEM character set.
    1. Ribbon Mode
      Click on ribbon tab Advanced on item Settings.

      Toolbar/Menu Mode with Contemporary menus
      Click in menu Advanced on menu item Settings.

      Toolbar/Menu Mode with Traditional menus
      Click in menu Advanced on menu item Configuration.
    2. Navigate in tree branch Editor to Word Wrap/Tab Settings and open this configuration dialog.
    3. Click on top right corner on button Change list.
    4. Click into the edit field and enter bat cmd (as space separated list of case-insensitive file extensions without asterisk and point).
    5. Click on buttons Add and OK.
    6. Select the list box item bat cmd.

      Attention: Take care not omitting this step whenever making changes on batch files related configuration.

      All settings displayed below are now for files with either file extension BAT or CMD. Configure the tab settings and the word wrap settings to your requirements for batch file editing.
    7. Click on button Font and select a font and a font size suitable for batch file editing.

      This step is very important. Don't skip it.

      In general the font should be a fixed width font (all characters have same width within a style) like Courier New. If bold/italic style are used for syntax highlighting batch files, it is strongly recommended to use a fixed pitch font (all characters in all styles have same width).

      It is also possible to check option Use OEM fixed pitch font, select an appropriate font like Terminal and let selection OEM/DOS as already preset for option Script. But I don't recommend usage of Use OEM fixed pitch font as in this case Windows defines the font, font style and font size. So which font, font style and font size is selected in font dialog does not matter with having Use OEM fixed pitch font enabled.

      Click on button OK to close the font configuration dialog.

      The font configured for batch files can be also the standard font as defined with menu item Set Font in menu View (traditional menus), or menu item Set Font in submenu Fonts in menu View (contemporary menus), or with popup menu item Set font of item Fonts on ribbon tab View (ribbon mode). But it is important to explicitly configure a font for bat cmd files.

      It is not possible to configure a font for hex/column edit mode for files of a specific file extension. For that reason a font selected for batch files being completely different to standard fonts used for all other files in text/hex/column mode results often in a dramatic display change on enabling/disabling column mode for a batch file.

      I configured as font for the batch files the same font as used by default for other files in all 3 editing modes, but with a larger font size than normally used for batch files. Therefore a switch to column mode on an opened batch file results with my font configuration in a text size decrease of the displayed text and in a text size increase on switching back to standard text editing mode. I like that noticeable text size decrease/increase on enabling/disabling column mode for batch files.
    8. This step is optional. There is in configuration tree File Types containing the list item Batch Files, (*.bat) with just *.bat. This file type specification can be changed to support also *.cmd files.
      • Select the list item Batch Files, (*.bat),
      • edit *.bat in File names edit field to either *.bat;*.cmd or *.cmd;*.bat,
      • modify Batch Files, (*.bat) in File descriptions edit field to Batch Files, (*.bat, *.cmd) or Batch Files, (*.cmd, *.bat) and
      • click on button Replace.
      This file type specification can be moved up or down using the buttons Up and Down. If the file types list item for batch files is the first one in the list, this file type specification is used by default in File - Open and File - Save As dialog.

      The file names order defines the default file extension on using Save As and having selected the file types list item for batch files and the entered file name does not end with either .bat or .cmd on clicking on button Save. The first time saved batch file gets .bat as file extension with *.bat;*.cmd defined as file names, but .cmd is appended on save to file name with *.cmd;*.bat defined as file names.
    9. Click on button OK to save modified configuration and close the configuration dialog.
    The configuration is done when having a font set for *.bat and *.cmd files with font option Use OEM fixed pitch font checked, at least for Western European and North American countries (other regions not evaluated by me).

    The following changes are made in uedit32.ini or uedit64.ini or uestudio.ini for bat cmd list item in Word Wrap/Tab Settings with
    • no Auto-complete file specified,
    • Use spaces in place of tabs checked,
    • a Tab stop value of 4 and an Indent spaces value of 4,
    • Default word wrap on for each file not enabled,
    • Terminal Regular 12 with Use OEM fixed pitch font checked,
    • Wrap at window edge selected and 80 set for not used option Wrap column #.
    [Font]
    OEM Fixed Font2=1

    [Font2]
    CharSet=255
    CharSetDef=0
    FaceName=Terminal
    Height=-16
    PitchAndFamily=49
    Weight=400

    [Settings]
    File Extensions2=bat cmd
    Force OEM2=0
    Indent2=4
    TabStops2=16
    UseSpaces2=1
    Wrap Column2=80
    Wrap Type2=0

    The section [Font2] was added as whole thing because of the batch files specific configuration. All other settings existed already and therefore just their values changed or were kept if being identical with the corresponding default value.

    For comparison the changes in the INI file in %APPDATA%\IDMComp\UltraEdit respectively %APPDATA%\IDMComp\UEStudio with
    • no Auto-complete file specified,
    • Use spaces in place of tabs checked,
    • a Tab stop value of 3 and an Indent spaces value of 3,
    • Default word wrap on for each file not enabled,
    • Courier New Regular 14 with Use OEM fixed pitch font not checked,
    • Wrap after column # selected and 120 set for used option Wrap column #.
    [Font]
    OEM Fixed Font2=0

    [Font2]
    CharSet=0
    CharSetDef=0
    FaceName=Courier New
    Height=-19
    PitchAndFamily=49
    Weight=400

    [Settings]
    File Extensions2=bat cmd
    Force OEM2=0
    Indent2=3
    TabStops2=12
    UseSpaces2=1
    Wrap Column2=120
    Wrap Type2=1

    But with this configuration with Use OEM fixed pitch font not checked any opened batch file is still edited as ANSI file using Windows character set and not OEM character set.

    In this case additional configuration steps are necessary to enable OEM Character Set by default for all *.bat and *.cmd.


    Enable OEM Character Set for batch files
    1. Open any *.bat or *.cmd file.
    2. In a customized toolbar click on icon to Show font with OEM Character Set or in a customized menu View click on menu item OEM Character Set.
    That change is applied to every file displayed with current font settings group which is [Font2]. The OEM character set would be enabled for all files if there would be no font specified explicitly for bat cmd files. That's the reason why it is really important to configure also a font for bat cmd even if it is the same font with same style and same size as used by default for all other text files.

    Those 2 steps are simple when having this command available by default in menu View as prior UltraEdit for Windows v14.10 or prior UEStudio v6.60 or in an already customized menu or toolbar.

    But what to do when not having this command in a menu or toolbar because of using standard menus/toolbars of UE > v14.00 or UEStudio > v6.50?
    • Read topic Manual customization of command OEM Character Set and add this command to menu View or a customized toolbar depending on version of UltraEdit/UEStudio.
    • Alternatively enable the OEM Character Set for the batch files once directly in the INI file of UE/UES while no instance of UltraEdit/UEStudio is running.
      • Open from directory %APPDATA%\IDMComp\UltraEdit respectively %APPDATA%\IDMComp\UEStudio (or whatever is set as INI file directory) the file uedit32.ini (32-bit UE) or uedit64.ini (64-bit UE) respectively uestudio.ini (32-bit and 64-bit UES) with Windows Notepad or any other text editor, except UE for editing uedit*.ini or UES for editing uestudio.ini.
      • In section [Font2] change value of CharSet= from 0 to 255.
      • In section [Settings] change value of Force OEM2= from 0 to 1.
      • Save the modified INI file of UltraEdit/UEStudio and exit the other text editor.
    OEM Character Set is now enabled by default for any *.bat and *.cmd file.

    The settings in the INI file for the example with Courier New Regular 14 are after these last configuration steps:

    [Font]
    OEM Fixed Font2=0

    [Font2]
    CharSet=255
    CharSetDef=0
    FaceName=Courier New
    Height=-19
    PitchAndFamily=49
    Weight=400

    [Settings]
    File Extensions2=bat cmd
    Force OEM2=1
    Indent2=3
    TabStops2=12
    UseSpaces2=1
    Wrap Column2=120
    Wrap Type2=1

    Note 1: The selected font must of course support the OEM code page defined in Windows region and language settings to get the OEM encoded characters also displayed as expected.

    Note 2: The status bar displays still for example 1252 (ANSI - Latin I) although the opened batch file is encoded for example with OEM 850 (Western Europe) or OEM 437 (North America). The conversion from Windows-1252 (ANSI) to OEM 850/437 (OEM) is done with this configuration "on the fly" on typing which makes this configuration so useful for batch file coders not writing only in English in batch files.
    Best regards from an UC/UE/UES for Windows user from Austria