# Automatically convert “…” to “\ldots”

Is there a way to automatically convert a basic string into a command, for example converting instances of ... to \ldots? I have to work with a large number of plaintext files, and doing a dozen find/replace operations for each file is rather inconvenient.

-
Welcome to TeX.SE. Seems like a job that could easily be done outside of TeX with a simple sed script. But how would you want to handle the case where these should instead be \cdots? – Peter Grill Oct 22 '12 at 1:16
@PeterGrill something like find -name '*.tex' -print0| xargs -0 sed -i 's/\.\.\./\\ldots/' :) – cmhughes Oct 22 '12 at 1:37
@PeterGrill In text, ... should always be \ldots{}, so the case of \cdots{} might not apply to the OP. – Bruno Le Floch Oct 22 '12 at 4:05
With for example Notepad++ you can do one find/replace operation simultaneously on as many files as your memory allows to open. – Qrrbrbirlbel Oct 22 '12 at 10:45

There are some fonts that turn ... into Unicode Character 02026 "Horizontal Ellipsis" …, e.g. Linux Libertine and Junicode, which have this transformation as part of the "Common" Ligature set (OpenType feature liga). Since both fonts activate the "Common" ligatures by default, you don't need to do anything but use the respective font. Here's an example of liga on and off, with the output, and the OCR Layer of the PDF, i.e. what's copy-pastable and findable with the search function:

% compile with XeLaTeX or LuaLaTeX
\documentclass{article}

\usepackage{fontspec}

\usepackage{libertineotf}

\begin{document}

\libertine Linux Libertine:

{\addfontfeatures{RawFeature=-liga} Hey ... what’s up?}

{\addfontfeatures{RawFeature=+liga} Hey ... what’s up?}

\fontspec{Junicode} Junicode: % you need to have the font installed

{\addfontfeatures{RawFeature=-liga} Hey ... what’s up?}

{\addfontfeatures{RawFeature=+liga} Hey ... what’s up?}

\end{document}


Linux Libertine:
Hey ... what’s up?
Hey … what’s up?
Junicode:
Hey ... what’s up?
Hey … what’s up?


(Adobe Reader 10.1.4 on Win7 is actually able to find all four three-dot combinations if you search for either ... or …. Sumatra PDF 2.1.1 only finds the two specific ones for each.)

-