Tapatalk

Customize Select Word to include a dash, a dollar sign, or any other character as word char

Customize Select Word to include a dash, a dollar sign, or any other character as word char

1
NewbieNewbie
1

    Jul 11, 2007#1

    I have what is probably a new user question, but I can't seem to find the answer. While editing a COBOL program, I'd like a "word" to include a dash (e.g. FLD-LEN should be one word, not 2). This is particularly for select word (Ctrl-J) or as the default for Find.

    I've looked at all the configuration options, but can't seem to find a relevant option. Is there one and which is it?

    TIA

    6,685587
    Grand MasterGrand Master
    6,685587

      Jul 11, 2007#2

      No, the "Select Word" and the "Find dialog defaults to word under cursor" cannot be customized to include a dash as word character.

      There is the Ctrl+Dbl Click feature which can be used to select a string depending on delimiters - see Configuration - Editor - Delimiters and its help page.

      If you want something similar which you can execute with a hotkey, you need a macro saved into a macro file which is automatically loaded on startup of UltraEdit and has a hotkey. Hope following macro code does the job:

      UnixReOff
      Loop
      IfColNumGt 1
      IfCharIs "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_"
      Key LEFT ARROW
      Else
      Key Ctrl+RIGHT ARROW
      IfCharIs "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_"
      ExitLoop
      Else
      Key Ctrl+RIGHT ARROW
      EndIf
      EndIf
      Else
      ExitLoop
      EndIf
      EndLoop
      Find RegExp "[0-9a-z^-_]+"

      Add UnixReOn or PerlReOn (v12+ of UE) at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.

      The character - respectively ^- in the regular expression search string can be replaced by $ (for selecting a PHP variable beginning with $) or any other character. Other characters can be also just added. The escape character ^ in the regular expression search string is only needed for the characters - [ ] ^ while all other characters can be put within the square brackets of the expression without the escape character ^.

      See also Assign Ctrl+Double Click to keyboard.

      1
      NewbieNewbie
      1

        Sep 11, 2009#3

        Thanks Mofi. The macro works great. :D even better than ctrl+double-click. Example: AR03-I-OLD-ACTIVE-LST). ctrl+double-click selects the variable and the close-parenthesis, even though () are in the delimiters list in wordfile.txt for Cobol. The hotkey selects only the variable name, not the ")". I just need to assign it to a toolbar button, or to a click, something I can do with just the mouse. Thanks so much !!

        6,685587
        Grand MasterGrand Master
        6,685587

          Sep 12, 2009#4

          The delimiters for Ctrl+Dbl Click can be configured at Advanced - Configuration - Editor - Delimiters. This feature uses by design (and that is good) not the word delimiters of the syntax highlighting.

          You can't call a macro with mouse from a toolbar or menu. Fast executing a macro with the mouse is only possible with using an opened View - Views/Lists - Macro List view. Since UE v15.00 this view can be set as auto-hidding dockable view which would be the best for you using the mouse. But you can only add the command to toggle the macro list view to a toolbar to open/close the macro list view with the mouse and execute the macro with the mouse.

          10
          Basic UserBasic User
          10

            Jun 23, 2014#5

            I couldn't get the delimiter setting to work with $ to be able to utilize ctrl+double click. Could you give me what my left and right delimiters should be to get that to work?

            I tried a number of times after reading multiple times your post and Delimiters help page.

            I used the macro and added in $ in the 3 character sets, and assigned that to a hotkey, which worked for me to select "$blah" for example.

            Thanks

            6,685587
            Grand MasterGrand Master
            6,685587

              Jun 23, 2014#6

              For left delimiters use " !"#%&'()*+,-./:;<=>?@[\]^`{|}~" without the red formatted double quotes just used here to show you that the first character is a space character.

              For right delimiters use " !"#$%&'()*+,-./:;<=>?@[\]^`{|}~" again without the red formatted double quotes.

              If the list of delimiter characters is compared with the list of characters displayed in View - Views/List - ASCII Table from space to tilde character, you will see that the left delimiters list contain all characters except dollar sign, digits, letters and underscore. And the right delimiters list is the same as left delimiters list with the exception of dollar sign also being added.

              Well, both list of delimiter characters are too long as the maximum is 30 characters. You should remove those characters from both lists which are never left or right of a variable starting with a dollar sign. For example #:@^` could be removed from the lists to decrease the number of characters below limit of 30 delimiter characters in total.

                May 26, 2018#7

                The third requested enhancement (configurable character set of word characters) based on the large enhancement request written by me was introduced with UltraEdit for Windows v25.00.0.82 and UEStudio v18.00.0.18.

                A string starting with non-word character $ like $variable is selected with including the dollar sign on
                • double clicking on $variable with pointing device;
                • pressing hokey Ctrl+J to select the word at current position of caret;
                • clicking in ribbon mode on ribbon tab Edit in first ribbon group Select and delete on down arrow of first item Select and next in popup menu on item Select word;
                • clicking in toolbar/menu mode with contemporary menus in menu Edit in submenu Select on menu item Select word;
                • clicking in toolbar/menu mode with traditional menus in menu Edit on menu item Select word.
                But $ is interpreted as word character anywhere within a string for selection only if the string is within a file or section syntax highlighted with a syntax highlighting language with language marker PHP_LANG which means the string must be part of a PHP code block according to syntax highlighting.

                Pressing Ctrl+F to open Quick find or Alt+F3 to open regular Find (with default key assignment) or Ctrl+R to open Replace or Ctrl+Shift+F to open Find in Files with caret anywhere within $variable results also in getting the variable with the dollar sign preset as string to find.

                The built-in enhancement for PHP code was removed in UE v25.10 and UES v18.10 because of /Word Select Include = feature introduced with those versions which makes it possible for every user to customize the word selection/navigation behavior for syntax highlighted files.

                Update on 2021-01-31:

                The first (configurable case matching behavior) and second (configurable whole word matching behavior) requested enhancements were introduced with UltraEdit for Windows v28.00 and UEStudio v21.00 offering at Advanced - Settings or Configuration - Search - Advanced for Highlight all occurrences of selected word the configuration settings:
                • Match case
                • Match whole word only
                  • ... when selection is whole word only
                Best regards from an UC/UE/UES for Windows user from Austria