Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Of course, any LaTeX editor will autocomplete common LaTeX commands and environments. Many (most?) let user add new commands to be autocompleted. However, in technical documents there will usually be specific terms, which are encountered often enough (and may be quite long) to be worth autocompleting, but aren't commands and are different from one document to another. So it's quite nice to be able to autocomplete any word which exists in the document (or any of the open documents).

I know Emacs, Vim, Kile and TeXstudio support this; do any others?

share|improve this question
    
So these "specific terms" are not commands themselves, as in \blahblah...? I know that's a very technical command. :-| –  Werner Oct 16 '11 at 17:19
1  
Textmate (macromates.com) does that. –  topskip Oct 16 '11 at 17:55
    
@Werner: Yes. E.g. you are writing an article on synchrocyclotrons or something, and don't want to write the word "synchrocyclotron" out each time. –  Alexey Romanov Oct 16 '11 at 18:14
1  
@AlexeyRomanov: Did you know that it is possible to define a command (say) \sync that expands "What mighty \sync you have, sir!" to "What mighty synchrocyclotrons you have, sir!". Any LaTeX editor can do this, but it is restricted to control sequences/commands (prepended with ``, in the general sense). –  Werner Oct 16 '11 at 18:26
    
@Werner: Yes, of course, that's an option. –  Alexey Romanov Oct 16 '11 at 18:28

10 Answers 10

up vote 8 down vote accepted

Any LaTeX editor can accommodate this style of auto-completion by means of macro definitions. It is probably the fastest way to perform this without having to switch from your existing editor to a new/different one. In my opinion, it is flexible, transferable and accommodates a host of variability that you may require based on (say) conditional support from LaTeX packages.

Since the replacement text is typically used inside regular text, the xspace package is of great help. It inserts a space after a command sequence only if it is followed by a space. This is a common issue with using command sequences in regular text. For example, A \TeX command sequence. will expand to A TeXcommand sequence. since the space represents the end of \TeX and is therefore gobbled. xspace is the way around this:

\documentclass{article}
\usepackage{xspace}% http://ctan.org/pkg/xspace
% Definitions for words to auto-complete
\newcommand{\sync}{synchrocyclotrons\xspace}%
%...
\begin{document}
What mighty \sync you have, sir! Get me one of those \sync.
\end{document}

enter image description here

If you change your mind (to quote ABBA), you can just change the macro definition. It would probably be the same amount of effort to do this than it would to modify the auto-completion segment provided by such an editor.

To go one step further, you can even define your macros to have (say) starred version * which expand to the plural form if use, otherwise it uses the singular form:

\documentclass{article}
\usepackage{xparse}% http://ctan.org/pkg/xprase
\usepackage{xspace}% http://ctan.org/pkg/xspace
% Definitions for words to auto-complete
\NewDocumentCommand{\sync}{s}{%
  synchrocyclotron\IfBooleanTF{#1}{s}{}\xspace
}
%...
\begin{document}
That's a huge \sync! There are plenty more \sync* over there.
\end{document}

enter image description here

The xparse package provides an easy interface for working with starred versions of commands/environments.

share|improve this answer

In addition to AucTeX commands of insertion/completion for macros or environments, emacs provides a specific method to expand any word in any buffer and in any mode: the command dabbrev-expand (M-/).

dabbrev-expand expands to the most recent, preceding word for which this is a prefix. If no suitable preceding word is found, words following point are considered. If still no suitable word is found, then look in the buffers accepted by the function pointed out by variable dabbrev-friend-buffer-function.

A positive prefix argument, N, says to take the Nth backward distinct possibility. A negative argument says search forward.

If the cursor has not moved from the end of the previous expansion and no argument is given, replace the previously-made expansion with the next possible expansion not yet tried.

(The latter feature is very handy...)

share|improve this answer

Kile has autocompletion for all words in the document. This is the documentation for that feature.

share|improve this answer
1  
The OP has already mentioned Kile :) –  topskip Oct 16 '11 at 17:54

TeXworks has some builtin autocompletion, but take a look at the script autocompleteForTexworks. The script can perform completion on long words earlier used in your document, labels and filenames for \input, \include and \includegraphics macros. In addition it can also close earlier opened environments.

There is a video of it in action on youtube.

Guide to use.

  1. start typing the long word that should be autocompleted
  2. press "crtl + m" and the autocompleter will complete the word or at least make a suggestion for a completion.
  3. if not satisfied with the suggestion press "crtl + m" until the correct word is found.

Disclaimer: I'm author of the autocomplete script.

share|improve this answer

If you are using Windows - TeXStudio (earlier TeXmakerX) has these facilities. The down side is everytime you time some environment or command it shows the complete help for it!

share|improve this answer

Use vim with the Supertab plugin. So you can type in the first letters of your long word and than type TAB.

share|improve this answer
    
Or ctrl-N and Ctrl-P without any plugin. –  Mariano Suárez-Alvarez Jul 2 '13 at 3:50

On Windows, Notepad++ has that capability. You will find instructions on how to set up Notepad++ as an LaTeX IDE in this StackExchange message.

share|improve this answer

For Mac OS X, BBEdit includes words from the current document as autocompletion candidates.

share|improve this answer

Texmaker is the best typesetting editor which I've worked with. It has versions for Linux, Windows & Mac.

I used it in Windows which has many auto-completion commands, and provides a dictionary for many languages.

share|improve this answer

For WinEdt (Windows) there are two macros for auto-completion on WinEdt's community site:

  • complete will incrementally search backwards for words starting with the same letters as the current word; you can invoke the macro multiple times until you get the word you are looking for;
  • completeWord will instead present you a list of possible completions to choose from.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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