How to quick enter the math mode delimiters ($ $) using WinEdt?

There's no predefined shortcut for this in WinEdt.

Anyway you can add one, for instance Ctrl+J which is not used anywhere else.

To do this (assuming you have version 7 or greater), go to "Options" -> "Options Interface" and, in the branch "Menus and Toolbar", double-click on "Main Menu". A local copy of the file MainMenu.ini will be opened.

At this point, locate the item

ITEM="$...$"
  CAPTION="$...$"
  IMAGE="Omega"
  MACRO="IfSel(2,'>',!'SetSel(0);');InsLabel('','$','$');"
  REQ_DOCUMENT=1

and add the line

  SHORTCUT="16458::Ctrl+J"

so to have

ITEM="$...$"
  CAPTION="$...$"
  IMAGE="Omega"
  MACRO="IfSel(2,'>',!'SetSel(0);');InsLabel('','$','$');"
  SHORTCUT="16458::Ctrl+J"
  REQ_DOCUMENT=1

Now press Shift+Ctrl+F9 to incorporate the changes and you're done.

As you can see in the "Insert" -> "LaTeX" menu, now the item "$..$" has the proper shortcut.

enter image description here


If you also want a button in the toolbar that is associated with that command, do the following.

In the same branch of the "Option Interface", double-click on "Toolbar". A local copy of the file Toolbar.ini will be opened.

Now locate the line

BUTTON="Emphasize_(Italic)"

and just before it, insert the line

BUTTON="$...$"

As before, press Shift+Ctrl+F9 to incorporate the changes.

And here is your toolbar button:

enter image description here


Another solution is to use the following macro, heavily inspired by the fonts macros:

BeginGroup;  
IfSel('0','=',>  
  'SelWord(1);>  
   IfSel(''0'',''='',>  
         ''Ins("$  $");>  
           PreviousBullet;'',>  
         ''InsLabel(""," $ "," $ ")'');',>    
  'InsLabel(""," $ "," $ ");');  
EndGroup;  
End;

that is to be stored in %b\Local\macros\, say, as insmath.edt. Then you add an item to the SHORTCUTS menu in MainMenu.ini, and locate the line: END="Shortcuts". Add just above this line the item:

ITEM="InsertSel $ $"
  MACRO="Exe('%b\Local\macros\insmath.edt')"
  SHORTCUT="16570::Ctrl+$"
  REQ_DOCUMENT=1  

Its job is to insert a $ $ pair on either side of a selection, selecting first the closest word if no selection is done.

You can also add two lines just above the END="SelectedPopup" line in PopupMenus.ini:

ITEM="Insert $  $"
  MACRO="[InsLabel('','$ ',' $')]"

You'll have access to this menu item with a right click on a selected text.

If you just want to typeset $ $ and get the cursor amidst, with only one key, you can make $ an active string adding these lines at the end of ActiveStrings.ini:

STRING="$"  
  START_FILTER="~\"  
  AFTER=0  
  ENABLED=1  
  MODE_FILTER="TeX"  
  MACRO="[SelCharLeft;Ins(' $  $');PreviousBullet;]"

Now $ is a shortcut, provided that you're in TeX mode and you did not type \$. As far as I can see it, there is no other situation in which one might type $for something else than entering in-line math mode.

Of course you'll have to incorporate the changes to each of the modified .ini files (Load Current Script in the Options Interface).