# Tag Info

27

I will not provide an in-depth comparison, as I only have limited experience with the different plugins. I know a couple of plugins well (LaTeX-Box and LaTeX-Suite), and I know one plugin very well, since I am developing it myself: vimtex. Thus, I will mostly write about vimtex. However, I will first point out some references that might be of interest to ...

12

I can't do comparison, as Vim-LaTeX is the only LaTeX plugin I've used. I have been using Vim-LaTeX for almost a year. So I will talk about Vim-LaTeX alone. There are many features present in Vim-LaTeX. I don't remember all of them. I'll just talk about features that I know and use constantly. Note: These are my limited user experience, which may be very ...

10

I don't know LaTeX but this seems to work: vnoremap iq :<C-U>silent! normal! t'vT<CR> omap iq :normal viq<CR> I based this off the information over here: http://vim.wikia.com/wiki/Creating_new_text_objects You can add support for aq as well: vnoremap aq :<C-U>silent! normal! f'vF<CR> omap aq :normal vaq<CR>

9

To expand commands in LaTeX, I use a dictionary copied from latex-suite (in details, this one) and put it in ~/.vim/dictionaries and then using autocmd FileType * exec("setlocal dictionary+=".$HOME."/.vim/dictionaries/".expand('<amatch>')) set completeopt=menuone,longest,preview set complete+=k Idea from here. I use it with supertab; the dictionary ... 7 Edit: I just discovered the vim-textobject-latex plugin, which adds the exact functionality you're looking for (in addition to a few other things). From the plugin's README: Currently supported text objects are: a i Description a\\ i\\ Inline math surrounded by \$$ and \$$. a$ i$Inline math surrounded by dollar signs. aq iq Single-quoted ... 7 When there's not enough information to decide otherwise, 'filetype' is set to the most basic -- plaintex. Your existing file must have had enough content for the detection to determine that it was actually LaTeX, so 'filetype' was set to tex. The required command to prefer LaTex when there isn't enough information is let g:tex_flavor = "latex" Note, that'... 7 % indeed stands for the current file. %:r (see :help filename-modifiers) strips off the file extension. You can then use :! to launch an external command, e.g. the PDF viewer: :! zathura %:r.pdf 7 If you use the vimtex plugin, you can: Change an enclosing command using csc: According to the help, a ysc corresponding to the commands offered by surround.vim isn't available, but can be added. See :h vimtex-faq-surround: *vimtex-faq-surround* Q: |vimtex| provides dse, dsc, cse, and csc. ... 6 What you ask is possible, but the solution is nontrivial. Both LaTeX-Box and vimtex has implemented solutions for this, see here: LaTeX-Box/ftplugin/latex-box/motion.vim:57 (s:FindMatchingPair) vimtex/autoload/vimtex/motion.vim:303 (s:highlight_matching_pair) These functions are run by autocommands whenever the cursor is moved, see here (LaTeX-Box) and ... 6 One way to do it employs the ie (inside-environment) custom text object, available in a number of places: e.g. in the plugin vimtex, or with vim-textobj-latex (and there are others). With this functionality, then the rewrap command becomes: gqie or gwie (to maintain cursor position). If you only want to reformat text from current text position (I see ... 6 Don't be so inefficient! Your time is valuable. Use the vimtex plugin offered by @lervag: see here. You can control all of the plugins you install by using Vundle or any similar plugin manager (vim-plug is getting pretty popular). Why waste your time installing vimtex? Great question! Features Continuous compilation using latexmk (please and thank you!) ... 6 To avoid leaving the buffer for entering the password, you can use sudo's -S flag: -S, --stdin Write the prompt to the standard error and read the password from the standard input instead of using the terminal device. The password must be followed by a newline character. Then your function could look like: function! ... 6 You are looking for set iskeyword-=: That is, making : explicitly not a keyword character. If : is in iskeyword it will be included in ciw. 5 If the chapter, section etc. labels are in the same file, or in any other open buffers, you can still use Ctrl-n/Ctrl-p. You just have to add : to the keyword characters, with: :set iskeyword+=: This enables (no more than) the following: if you write c:blah somewhere, c: followed by Ctrl-p (or Ctrl-n) is able to later offer it for autocompletion. 5 Perhaps like this: let s:TeXmaps = { \ 'a': '\alpha', \ 'b': '\beta', \ '->': '\to', \ '=>': '\Rightarrow' } function! <SID>IsTeXMath() return &ft ==# 'tex' && match(map( synstack(line('.'), col('.')), 'synIDattr(v:val, "name")' ), '\m^texMathZone[EX]$') >= 0 endfunction for s:k in keys(s:TeXmaps) ...

5

First: Did you bother to read the vimtex documentation, i.e. :h vimtex-folding? The docs clearly point out that the fold-expr method of folding is slow, and so therefore provides an option g:vimtex_fold_manual which if enabled (set to nonzero value) will set foldmethod=manual, and instead will remap zx and zX to recalculate the folds when necessary (...

5

First: This is not related to vim-lexical. Syntax rules define where spell checking should be done, and so the current behaviour is defined by the internal syntax plugin for LaTeX. The default syntax rule for tex command arguments allows spell checking. Some commands, e.g. \include{...}, are not spell checked. This is controlled by the @Spell and @NoSpell ...

5

I would say that you are approaching this the wrong way. If you want to use a very minimalistic solution without any plugins, I would claim that you should not have anything in your vimrc file for compiling. Instead, you should use latexmk. This is a very good automatic compilation tool for LaTeX, which will compile as many times as necessary, including ...

5

The reason this is happening is because the indentexpr [1] prefers text to be indented inside \items. You can see this by pressing gg=G. This is what it considers correct indenting: \begin{document} \begin{itemize} \item Here is an equation: \begin{align*} x = y \end{align*} \item Here is another item \end{itemize} \end{...

5

Rather than figuring out what's going on with your existing mappings, it's easier and more readable just to use a function, instead: nnoremap <F5> :call <SID>compile_latex()<CR> function! s:compile_latex() abort write if expand("%") == "body.tex" !arara -v "main.tex" else !arara '-v %' endif endfunction N.B. The :execute ...

5

This can be done with either regex+substitute or macros Substitute. This is the same as your regex except the important parts are surrounded by $$.$$ to create capture groups. These are referred to by submatch(1) and submatch(2) respectively. We use the replace expression \= and execute('let') idiom. Finally, use /n to prevent substitution from ...

4

While infuriating, a number of vim-latex's features can be customised without editing the source code. Disable the EEA mapping In .vim/after/ftplugin/tex.vim, add call IMAP('EEA', 'EEA', 'tex') Typing EEA in insert mode will no longer insert the eqnarray environment. F5 prompted environments In .vim/ftplugin/tex/texrc, add: let g:...

4

This is a very difficult problem. It is such a corner case of what people need, that I would not personally want to support it directly. Thus I also won't try to come with a direct answer to your question. Instead, I want to propose two indirect solutions: Put the unmatched paranthesis inside a verbatim command, e.g. \verb+(+. Create a new command for the ...

4

By placing that line by itself in ~/.vim/after/syntax/tex.vim instead of adding it to a copy of $VIMRUNTIME/syntax/tex.vim in ~/.vim/syntax/tex.vim, the spell checking behavior was disabled between \beq and \eeq tags as I wanted. Unfortunately, this line doesn't tell Vim it's a math region, so math syntax highlighting is different between these tags than it ... 4 One way to get this effect is to instead adaptively enter either $$or$$ depending on which is needed. So the first$ will type $$and the second will type$$. To figure out which we need, we use searchpairpos, which returns [0,0] when outside the $$..$$ pair. Besides being cleaner to code, it is also a bit nicer while typing and works over multiple ...

3

Rather than changing the way text is actually stored by writing a custom 'formatexpr', I'd be tempted to just to use Vim's existing features to solve the stated goals of easy readability and easy "diff"-ability. Long lines are easily readable in Vim with the following set: :set wrap :set linebreak And changes towards the end of a line are also perfectly ...

3

For the first situation (tex selection to PDF) if you have a tex compiler that allows for input from stdin you could echo your visual selection. function! EchoPipeCmd(cmd) range echo system('echo ' . shellescape(join(getline(a:firstline, a:lastline), "\n")) . ' | ' . a:cmd) endfunction command! -range=% -nargs=+ EchoPipeCmd :<line1>,<line2>...

3

The documentation for the indentation plugin for LaTeX is unfortunately not available in the help files, but it is written in the source code in $VIMRUNTIME/indent/tex.vim. The following variables are available for customization: g:tex_indent_brace: Toggle smartindent-like style for {} and []. g:tex_indent_items: Indent continuation lines after \items. g:... 3 lh-brackets provides the Map4TheseContexts() function that takes care of detecting the context to do different things. " To be defined in a tex ftplugin -> ~/.vim/ftplugin/tex/your-shortcuts.vim :inoremap <buffer> <silent> a <c-r>=Map4TheseContexts('a', 'texMathZone', '\\alpha', '`a')<cr> " or: :inoremap <buffer> <... 3 Your$ match is ignored, % searches forward for the first character in a pair that it knows about: so it finds { and then the matching }, and moves between them. From :h mps: Only character pairs are allowed that are different, thus you cannot jump between two double quotes. One solution would be: to use the 'matchit' plugin (which allows for ...

Only top voted, non community-wiki answers of a minimum length are eligible