Closed goduck777 closed 5 years ago
The reason for this is that the current line is reindented on certain specified keys, which are not typed when you do it<tab>
. Thus the tab before the \item
will not be removed.
Personally, I've solved this particular issue by defining a mapping for inserting the items, i.e. I have the following in my personal ftplugin/tex.vim
(can also be put in ftplugin/after/tex.vim
).
call vimtex#imaps#add_map({
\ 'lhs' : '<m-i>',
\ 'rhs' : '\item ',
\ 'leader' : '',
\ 'wrapper' : 'vimtex#imaps#wrap_environment',
\ 'context' : [
\ 'itemize',
\ 'enumerate',
\ {'envs' : ['description'], 'rhs' : '\item['},
\ ],
\})
However, Ultisnips is powerful, and I'm sure you can solve this with it as well. I'm no expert, but it seems this might be close to what you want to do.
I'm closing the issue, but feel free to continue the discussion.
Thank you for your answer. This is not exactly what I want. I am looking for auto-indenting the line after the snippet expand. The ultisnips trick you suggests gives a fixed indent, but not a smart indent according to the context.
I will submit an issue to ultisnips for this problem.
Ok, thanks. Feel free to make a reference to the Ultisnips issue when/if you create it.
@goduck777 there is already this possibly related issue https://github.com/SirVer/ultisnips/issues/913
@andymass Thank you, this is what I want.
@lervag Why does vimtex autoindent after a line containing \item? Is there a way to disable that.
@cuppajoeman Please don't ask new questions in old threads. It is much better to open a new issue.
The why: Because I've found it convenient to "descramble" the \item
lines from the remaining lines in itemize environments. That is, because I like it this way. But of course, it is configurable. The details are explained in SNIPPET REMOVED:help g:vimtex_fold_types
. For your convenience:
EDIT: Remove erroneous statement about configurability.
@lervag The command would be let g:vimtex_fold_types = {'items' : {'enabled' : 0}}
according to the doc I believe, and as for me, it does not work.
(i.e., when pressing ENTER in an itemize environment, I get an additional indent like
\item blabla (ENTER pressed)
| <--- now here :-(
Sorry, my mistake. The g:vimtex_fold_...
is of course not relevant for indents. Thus, there is currently no option to disable this kind of indentation. Feel free to open a feature request if you believe this would be a valuable feature.
@lervag Thanks a lot
It would be nice to be able to disable this. Is it still not possible?
@awa5114 This was never opened as a feature request. If you want it, please open a feature request and describe what you want.
Vimtex can handle the indent of \item very will in most cases.
In Ultisnips (or other snippet plugins), there is a very convenient way to input \item. Like, I can just type it\<tab> to get a \item. However, in this case vimtex gives the wrong indent. The tab before \item is not eliminated. The result is like
Is there a fix for this problem? or is there a better way for inputting \item?