WinEdt Macro Library  | text previous macro  | next macro



This macro will insert (single or double) quotes depending on the document's mode or submode. Additionally, it's a bit smarter than WinEdt's default Smart Quote.edt macro.

It will not simply toggle quotes, but will determine whether opening or closing quotation marks are desired by looking at the preceding character. (You can turn off extra smartness by changing one line in the macro file.)

The quotation style will be determined as follows:

  1. If a style for the document's mode is defined (e.g. TeX, or TeX:DE), take the corresponding quotes;
  2. else try whether a style is defined if we subtract submode(s)
    (e.g. if the document's mode is TeX:US:UNIX, it would be TeX:US, if it were TeX:ES:MAC, it would be TeX).
  3. If it's a TEX document, the macro will also search the document's preamble for a line like:
    % !smartQuote:: "French"
  4. If all fails, take default quotes.

It is also possible to have both opening and closing quotation marks typed in one go (useful for programming).


Put the macro in %b\Macros\text\, and assign a shortcut to it:

For WinEdt 5.6 or older:

  1. go to Options | Menu Setup | Main Menu, double-click on Shortcuts,
  2. at the end of the list, Insert a new Macro item called "Smart Double Quotes",
  3. the Macro field must contain:
  4. Click in the Shortcut field and type the double quote character " (this will be translated to the actual combination of keys that produces a double quote on your keyboard).
  5. Optionally, repeat these steps for the single quote character.
    (Here, the Macro field must read:
    and the shortcut must be the single quote character ' )

For WinEdt 6.0 or newer:

  1. add the following lines to the "Shortcuts" submenu in the Main Menu (accessible through the Options Interface):
      CAPTION="Smart Double Quotes"
  2. in the last line, insert the shortcut for the double quote character (by double-clicking on "SHORTCUT" or using the Insert Shortcut button)
  3. Optionally, repeat these steps for the single quote character:
      CAPTION="Smart Single Quotes"

You do not need to add a second shortcut to be able to insert a normal quotation mark (as was necessary with previous versions of this macro). Instead, typing the quotation mark twice will give you the default. (This, too, can be turned off.)


You can easily define different types of quotation characters for modes, submodes, and have local styles for TEX files.



Macro contributed by Robert <>

WinEdt Macro Library  | text previous macro  | next macro