Vimtex: Placeholder for math input

Created on 8 Sep 2016  路  8Comments  路  Source: lervag/vimtex

It is a great plugin, and I would like to use it now instead of latex-suite. I find that there are some key mapping are similar to latex-suite, e.g. `a will get \alpha in math mode. There are so many features I like it very much, such as view toc. And with latexmk engine, I can update the document based on cursor move to preview the pdf in realtime...

But, I believe there is one more thing should also keep working, that is, when I type $$, it expands to $$<++> and place cursor between $$ for input, and then after that, I can press Ctrl+j to jump out of $$ (this is a feature in latex-suite, in case I don't clear myselft, please have a try of latex-suite). How can I do this?

Most helpful comment

I'm sorry if the following will sound snarky or bad mannered. But you have to realize that I have spent a lot of time developing vimtex, and that there have been a lot of well thought out ideas. I don't get paid for any of this work. I give it away freely. I even spend my spare time helping people like you to use it and to improve the plugin for your sake.

I really don't care if you want to use the plugin or not. However, I will help you make it work as intended, and I will answer questions regarding the use of Vim for LaTeX. As I have already done. Your comment implies that you want to use an editor that "just works". Vim is not that editor. To use Vim, you really should learn how to use it. You don't need to be an expert, but you can't possibly believe that everything will just work and that the documentation for Vim and for plugins are written for no good reason. I understand that reading the vimtex documentation might take some time, but you should understand that writing it took a long time, and that writing vimtex took a long time. If you can't even invest the time to read the docs, then why the ... should I invest the time to answer your questions?

So: Yes, to use my plugin, you _should_ spend some time to read about how things work. If you don't want that, then perhaps you should use a different text editor? See here for a list of TeX editors.

All 8 comments

The placeholders are not and will not be supported, but something similar is. Please see :h vimtex-imaps (read all of it). For $$ and similar, I show how to use either neosnippet or Ultisnips to get a similar functionality.

For more complex snippets, I very strongly suggest that you look into neosnippet or UltiSnips. Both of these provide a good snippet engine and the readmes explain how to get a good default setup.

To be more clear: The placeholder feature in latex-suite is actually the same as a snippet feature as provided by neosnippet and UltiSnips. There is no reason for me to implement this feature, because it is already implemented very well by both of those plugins. Instead, I suggest that you choose one of those as you prefer, and either implement custom snippets that suite your needs, or use one of the default packages.

I have taken a look at the examples you given in vimtex-imaps, It seems that you only provided a command similar to IMAP of latex-suite, which can be almost replaced with the latex build in command \newcommand{\lhs}{\rhs}.

I think it is not convenient for users like me who are not familiar with vim or the snips plugin to write the placeholder and environment auto complete command manually. I hope anyone here can help me to solve the following problems, which has the same goal: How to type math quickly

  1. How to insert environment such as equation/align fastly?
    I believe there should be something like when I type \beg then Tab it will prop up a menu or I can type directly the environment. And what's more, there should be placeholder to make me jump quickly.
  2. How to insert documentclass/usepackage/newcommand quickly?

May I suggest that provided a video guide to show how to type/modify a real mathematical article with this plugin?

Can I just take a use of Latex-suite's imaps.vim in which the IMAP and jumps defined. I try to copy it into vimtex's autoload, but not work.

No, you misunderstand. But I might not have been clear. What is supported in vimtex is simple mappings in insert mode that completes e.g. `a to \alpha. More complex mappings are not supported, and will never be supported. This is because the feature you want is provided by other plugins that already solve the problem in a much more general way, i.e. neosnippet and UltiSnips. Both of these plugins allow you to define so called snippets, that you can expand e.g.

% Type "begin<expand key>" to get:
\begin{[cursor is here]}
...
\end{...}

That is, this feature is supported by latex-suite with the jump markers, but that is a poor implementation. Both neosnippet and UltiSnips is much better, and can be used for other languages as well.

So, to answer your question "How to type math quickly":

  1. Use the simple mappings provided by vimtex (see :h vimtex-imaps for more info and here for a list of supported mappings).
  2. Use neosnippet or UltiSnips for advanced snippets and expansions, such as for equation, align, etc.

Regarding a video guide: I don't have the time to make one. Sorry. But my suggestions should not take too long for you to investigate. In particular, UltiSnips has a huge fan base and should be relatively easy to learn.

It sounds like that in order to use your plugin, the user needs to be expert in vim and has a lots of time to investigate the feature of your plugin and help you to complement some part of lossed feature? In that case, I just doubt you will lose quite a part of potential user including me!

I'm sorry if the following will sound snarky or bad mannered. But you have to realize that I have spent a lot of time developing vimtex, and that there have been a lot of well thought out ideas. I don't get paid for any of this work. I give it away freely. I even spend my spare time helping people like you to use it and to improve the plugin for your sake.

I really don't care if you want to use the plugin or not. However, I will help you make it work as intended, and I will answer questions regarding the use of Vim for LaTeX. As I have already done. Your comment implies that you want to use an editor that "just works". Vim is not that editor. To use Vim, you really should learn how to use it. You don't need to be an expert, but you can't possibly believe that everything will just work and that the documentation for Vim and for plugins are written for no good reason. I understand that reading the vimtex documentation might take some time, but you should understand that writing it took a long time, and that writing vimtex took a long time. If you can't even invest the time to read the docs, then why the ... should I invest the time to answer your questions?

So: Yes, to use my plugin, you _should_ spend some time to read about how things work. If you don't want that, then perhaps you should use a different text editor? See here for a list of TeX editors.

Or here.

As lervag already said, you have to invest some time, if you want to use vim as your editor and you have to invest a lot of time, if you want to use it efficiently.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dsevero picture dsevero  路  4Comments

chakravala picture chakravala  路  5Comments

benutzer193 picture benutzer193  路  4Comments

nbanka picture nbanka  路  5Comments

vsbuffalo picture vsbuffalo  路  3Comments