[Tex/LaTex] How to replace a hyphen (-) with an en-dash (–) automatically

formattingpunctuation

I would like to set up my LaTeX (XeTeX) document in such a way so that I could type a hyphen (-, the one on the keyboard) and it would get replaced with an en-dash (, the "longer" dash) in the resulting document.

For example, for a LaTeX source:

Lietuvos intelektualai - prieš liberaliąją demokratiją? % "Usual" dash typed

I would like to get the en-dash ("long" dash) in the rendering:

Lietuvos intelektualai – prieš liberaliąją demokratiją?

and not the usual hyphen ("short" dash):

Lietuvos intelektualai – prieš liberaliąją demokratiją?

I'm aware that this could be achieved by typing two hyphens (--) instead of a single hyphen (-), but is there a better way to do that?

(Due to the nature of documents I typeset and the requirements of the language I use, I'm required to type an en-dash 98% of all times and might need the "usual" hyphen just occasionally).

Best Answer

Found a workaround for XeTeX:

\usepackage{ifxetex}

\ifxetex
    \usepackage{xesearch}
    \UndoBoundary{-}
    \SearchList{dash}{--}{-}
\else
    \typeout{Well, too bad.}
\fi

Also, note the comments under the original question discussing why automatic replacements are not always a good idea.