2

I am not a serious programmer and this may just be over my head. But I would like to be able to create a few new buttons that would work the way buttons like \"o work in the WinEdt GUI Page Control bar do.

That is, you can select a letter, say "a", in your file, then click on the button \"o in the WinEdt GUI Page Control bar, and WinEdt will insert \"{a} in your file.

I have designed a few new commands sort of like \"{} (with help from Alan Munn How to use CJK ruby for diacritics only). And it would save me a lot of work if I could just select a character in the file and click a button and get one of these commands wrapped around that character.

Is there an easy way to do that?

As far as I can see the questions Quick Build commands in WinEdt and Adding a new command in Winedt 8 do not address my goal of getting the command wrapped around a piece of text.

6

Of course it is possible. Follow these steps.

  1. Show the "Options Interface" (Options -> Options Interface)

    enter image description here

  2. Double-click the "Main Menu" item (MainMenu.ini gets opened)

  3. Just before the line

    END="User_Menu"
    

    add the following lines

      ITEM="\""{}"  // use the name you want, but remember that this will be the name of your button
        CAPTION="\""{}"
        IMAGE="Delim"  // double-click on IMAGE and choose the image you want
        MACRO="IfSel(2,'>','SetSel(0);');IfSel(0,'=',|Ins('\""{}');"+
              "CharLeft;|,|InsLabel('','\""{','}');|);"
    
  4. Press Shift+Ctrl+F9

  5. Now (in the "Options Interface") double-click the "Toolbar" item (Toolbar.ini gets opened)

  6. Put the line

      BUTTON="\""{}"
    

    wherever you want in the file in the point where you want the button.

  7. Press Shift+Ctrl+F9


That's it. Now you have a toolbar button

enter image description here

that inserts what you wanted.


Notice that the character " is used by WinEdt as a string delimiter, so to obtain " you have to double it (""). The same might be needed for the character ' if you want to insert something with it.

For example, if you want a macro to insert \'{}, you'll have to use

    MACRO="IfSel(2,'>','SetSel(0);');IfSel(0,'=',|Ins('\''{}');"+
          "CharLeft;|,|InsLabel('','\''{','}');|);"
  • Grazie @Sebastiano – karlkoeller May 29 '17 at 20:13
  • You're great, I'm a lot worse. See also my score. I only answer easy questions. – Sebastiano May 29 '17 at 20:16
  • When you say "use the name you want," I believe the name goes this way: ITEM="\NAME_HERE""{}" but I am not sure. Is that right? Does the name also go after the backslash in CAPTION="\""{}"? – Colin McLarty May 30 '17 at 0:19
  • @ColinMcLarty ITEM is a symbolic name which serves as a refer for BUTTON in Toolbar.ini, while CAPTION is the name which will be displayed when the mouse hover over the button. CAPTION is also the name of the menu item as displayed in the menu (when visible). Try to change the property INVISIBLE from 1 to 0 for MENU="User_Menu" to see your commands in the main menu, also. – karlkoeller May 30 '17 at 4:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.