4

I have not done much with abbrev-mode or yasnippet, but I recently started using AucTex mode with great success, and I think some common TeX markup I'm inputting could benefit from expansion.

Example:

  • Type dots and get \dots{}
  • Type txt and get \textit{} (with cursor between the brackets)

I'm a beginner user, and abbrev-mode looks easier. However, I am not sure if it has the funcionality I'm looking for. If it must be Yasnippet, could someone advise on a good tutorial aimed at beginners?

Thank you, steven arntson

8

I'd use yasnippet for this, especially because of the desired cursor placement.

The first snippet could be something like

# -*- mode: snippet -*-
# name: dots
# key: dots
# --
\dots{$0}

You should store this file in a directory named latex-mode under a directory that is listed in yas-snippet-dirs. I think the official documentation is probably the best place to look for more information, but perhaps that's because I haven't actively looked for other information or tutorials.

  • 1
    Thanks for this---after some experimentation, it worked perfectly. Furthermore, I learned that once I have the cursor positioned between the brackets, I can add a command to TAB out of them when I'm finished with the entry: \textit{$1}$0 – Steven Arntson May 24 '15 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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