highlight different words in different colours

highlight different words in different colours

3
NewbieNewbie
3

    Jul 07, 2015#1

    Hello,

    I want to mark/highlight words in different colours.

    Is this possible with UltraEdit?

    When the FIND dialog is used I only can highlight all occurrences of the search phrase, but with the next search these highlighted hits are replaced by the hits from the new search.

    For instance I want to find all words orange, apple, kiwi in a text and want to highlight orange with orange colour, apple with red and kiwi with green colour.

    Is this possible?

    I read that maybe the syntax highlighting can be used, but this is not very flexible when I want to search for bananas instead of apples.

    I don't want to save file with colored text - I want to simplify finding text in a file for me.

    It would help a lot to highlight - NOT SAVE! - search terms in different colors.

    It helps to see what search term is next to another to avoid jumping over interesting parts in a TEXT file.

    Regards, Michael

    6,681583
    Grand MasterGrand Master
    6,681583

      Jul 08, 2015#2

      Highlighting search terms in different colors is not possible. Highlighting words (not terms) in various colors is possible only with syntax highlighting. You can open in same instance of UltraEdit the wordfile used to highlight the active file and add there the words you want to highlight at the moment to the color groups (up to 20). After saving the wordfile and switching back to the highlighted file you see the syntax highlighting now automatically according to last update of the wordfile. That's it. I have no other idea how to get temporarily highlighted various strings in various colors with UltraEdit.

      BTW: Searching with your eyes is nearly always less productive than searching with UltraEdit. Using Perl regular expression search string term 1|term 2|term 3|term 4 and using key F3 to find next occurrence of one of the 4 terms might be more efficient.
      Best regards from an UC/UE/UES for Windows user from Austria

      3
      NewbieNewbie
      3

        Jul 08, 2015#3

        Thanks for your response.
        I agree with you that "manual" search is not as good as searching with UltraEdit.
        I also see the way of syntax highlighting more or less as a solution. Will spend time to get more familiar with this

        Could you still explain how to open the actual used word file?
        In View->syntax highlighting-> is nothing selected (no highlighting)

        Do I need to create a new one (maybe based on another syntax highlighting such as Java or Perl and adapt it)

        Thanks

        6,681583
        Grand MasterGrand Master
        6,681583

          Jul 09, 2015#4

          Create a new ASCII file with DOS line terminators and copy and paste following lines into the file:

          /L20"Words" Nocase Noquote File Extensions = *
          /Delimiters = ! $tab'()*+,./:;<=>@[\]^`{|}~
          /C1"Color Red"
          /C2"Color Blue"
          /C3"Color Green"

          tab must be replaced after pasting by a horizontal tab character. You can add up to /C20"Color x" color groups.

          Save this file with name words.uew into the directory %APPDATA%\IDMComp\UltraEdit\wordfiles.

          Because of File Extensions = * all files not highlighted with a different syntax highlighting language because of file extension / name are highlighted with language Words as defined in this wordfile.

          Exit UltraEdit and restart UE. Open View - Themes - Manage Themes, switch to tab Syntax, select language Words and assign the appropriate colors to the color groups as defined in the wordfile.

          When a file is highlighted with Words as indicated in the status bar or in menu View - View as (Highlighting File Type), opening Advanced - Configuration - Editor Display - Syntax Highlighting and clicking there on button Open before closing the configuration dialog with button Cancel opens this wordfile again for changing the words in the color groups.

          But I suggest to add this wordfile to File - Favorite Files for quicker opening via the favorite files list.

          Or perhaps even better, you create a new ASCII file with DOS line terminators and copy and paste following block into the file:

          Code: Select all

          var bWordfileOpened = false;
          for (var nDocIndex = 0; nDocIndex < UltraEdit.document.length; nDocIndex++)
          {
             if (UltraEdit.document[nDocIndex].path.search(/\\words.uew$/) >= 0)
             {
                UltraEdit.document[nDocIndex].setActive();
                bWordfileOpened = true;
                break;
             }
          }
          if (!bWordfileOpened)
          {
             UltraEdit.open("C:\\Users\\UserName\\AppData\\Roaming\\IDMComp\\UltraEdit\\wordfiles\\words.uew");
          }
          
          The path in line with UltraEdit.open must be what Windows Explorer displays in address bar after copying %APPDATA%\IDMComp\UltraEdit\wordfiles into the address bar and hitting key RETURN to open this directory. There must be used 2 backslashes for each backslash in path because the backslash character is the escape character in a JavaScript string.

          Save this UltraEdit script now for example to %APPDATA%\IDMComp\UltraEdit\scripts (must be most likely created first) with name OpenWordsFile.js. Then open Scripting - Scripts and add this UE script to list of scripts. Assign a hotkey to this script for fast execution by this hotkey.

          Now when you want to change 1 or more words in wordfile words.uew, press the hotkey of the script and it will be opened or made active in case of being already opened and can be edited (after clicking into the wordfile). After saving the modifications the syntax highlighting for all files highlighted with Words changes.

          See help page Syntax Highlighting in help of UltraEdit for details on how to add the words correct into the color groups. Best is you add always only 1 word per line to a color group. Note: The lines in each color group must be sort alphabetically case-insensitive because of Nocase in first line. But that should not be a problem for you as you most likely add just a few words into each color group.
          Best regards from an UC/UE/UES for Windows user from Austria