Skip to main content
Share Your Experience: Take the 2024 Developer Survey
16 votes
Accepted

How do I get Vim to compile my .tex file when executing :w?

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-...
fuzzybear3965's user avatar
13 votes
Accepted

Why does vim still auto-indent LaTeX after I set noai noci nosi?

'indentexpr' has the highest priority of how vim can automatically indent lines. :h 'indentexpr': When this option is not empty, it overrules the 'cindent' and 'smartindent' indenting. Your ...
Hotschke's user avatar
  • 4,770
10 votes
Accepted

Why does Vim highlight "in" in tex files and how can I stop it?

You can find out what syntax item applies by positioning the cursor and using something like: :echo synIDattr(synID(line("."), col("."), 1), "name") Because that's quite ...
Martin Tournoij's user avatar
8 votes
Accepted

Unable to set iskeyword for colon ( : ) character

You are looking for set iskeyword-=: That is, making : explicitly not a keyword character. If : is in iskeyword it will be included in ciw.
Mass's user avatar
  • 14.1k
8 votes
Accepted

How to force vimtex to display \textbf and \textit in insert/normal mode?

This is not due to vimtex directly, but due to the conceal feature in Vim. vimtex only adds to the syntax plugin that ships with Vim/neovim, and it adhers to the relevant option, see :help g:...
Karl Yngve Lervåg's user avatar
7 votes
Accepted

Use search matches as parameters in external command

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 ...
muru's user avatar
  • 24.9k
7 votes

Yank both sides of equation

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 ...
Mass's user avatar
  • 14.1k
6 votes
Accepted

Why is my # mapping behaving oddly in TeX files?

This is probably because there's another multi-key mapping that starts with a #; this is added by the TeX-specific plugin you have and loaded only for those files. You can reproduce it with: inoremap #...
Martin Tournoij's user avatar
5 votes
Accepted

Compiling whole LaTeX projects

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 ...
Karl Yngve Lervåg's user avatar
5 votes
Accepted

Indentation in Latex within a list after an equation

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}...
Mass's user avatar
  • 14.1k
5 votes
Accepted

Syntax highlighting of underscores in LaTeX, even though they only appear in filenames

This is happening because the syntax file for LaTeX does not recognize \subfile{ as a command which takes a file name. You can customize this as follows. In your config directory (.vim, .config/...
Mass's user avatar
  • 14.1k
5 votes

Syntax of :endif in if-statements

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> ...
Rich's user avatar
  • 32.1k
5 votes
Accepted

Trigger reindentation after snippet has expanded to word in 'indentkeys'

You can manually fix the indent by typing CTRL-F (this is documented at :help indentkeys-format). Thus, an autonomous solution would be to issue this key-press after snippet expansion. global !p def ...
Mass's user avatar
  • 14.1k
5 votes
Accepted

Unable to conditionally test for presence of a plugin command & invoke it

The problem is, your vimrc file is executed before any plugins are loaded. You can check the order of what source files are loaded by issueing the :scriptnames command. The usual way to fix this ...
Christian Brabandt's user avatar
5 votes
Accepted

Silence command but not its output

As Ben said in the comments prompting the command used before its result is a built-in behavior that you can not change without modifying Vim's source code. However a possible workaround is to use :h ...
statox's user avatar
  • 50k
5 votes
Accepted

TeX/LaTeX vim fold markers options

You might want to consider adopting the vimtex plug-in, which improves support for TeX files in Vim. Among its features, it supports custom folding, which is able to recognize LaTeX blocks delimited ...
filbranden's user avatar
  • 28.9k
5 votes
Accepted

How is filetype tex and plaintex set in vanilla Vim?

The filetype of a .tex file is determined by the content of the file. In particular, if the first lines contains: %&plaintex then it will be considered plaintex, %&tex then it will be ...
Vivian De Smedt's user avatar
4 votes

How do I get Vim to compile my .tex file when executing :w?

If you use tpope's Dispatch plugin: https://github.com/tpope/vim-dispatch you can run commands in the background. I use this snippet to run xelatex on every save: augroup latex autocmd! ...
Arjen Dijkstra's user avatar
4 votes

Turn off Vim spellcheck in custom region

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 \...
Ben Lindsay's user avatar
4 votes

Using Text Objects with vimtex

I think you do not really understand what a text object is. I therefore recommend that you read :h text-objects. When you have read and understood this, you should be able to understand the vimtex ...
Karl Yngve Lervåg's user avatar
4 votes
Accepted

Replace text and move cursor to end of replacement in insert mode

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 ...
Mass's user avatar
  • 14.1k
4 votes

Syntax highlighting of underscores in LaTeX, even though they only appear in filenames

If you want to turn off this behavior in general, add following to your vimrc let g:tex_no_error=1 The documentation found under :h g:tex_no_error: is *tex-error* *g:...
Hotschke's user avatar
  • 4,770
4 votes
Accepted

Make conditional imap to text being enclosed in certain characters

This is actually a complicated matter. $...$ is a difficult construct to parse, because it has no clear beginning or end. That is, in math here? $ or math here? $ math here?, how do you know which ...
Karl Yngve Lervåg's user avatar
4 votes

VIM conceal doesn't work

The reason removing augroup remember_folds helped was given here: https://github.com/vim/vim/issues/4175. Basically neither mkview nor loadview remember filetype nor syntax. Quick fix to that problem ...
Michał Syposz's user avatar
4 votes

How to show all LaTeX code but still have set conceallevel=3 for vim-devicons and NERDTree?

I found the answer to my own question after hours of hunting. This post sheds light on the issue: https://stackoverflow.com/questions/18160953/disable-latex-symbol-conversion-in-vim It's resolved ...
Incalculon's user avatar
4 votes
Accepted

How to disable ligatures "inside the editor" while using vim for latex documents?

This is a part of standard filetype plugin, see :h tex.vim for a complete info. That particular feature is controlled by :h g:tex_conceal So it's enough to add let g:tex_conceal = '' to your vimrc (...
Matt's user avatar
  • 20.8k
4 votes

Latex Subscripts Rendering Weirdly

The problem is that the subscript for g doesn't exist, and those for h and i look "off." As noted, you can either turn off the conceal feature altogether (set conceallevel=0) turn off conceal in tex ...
D. Ben Knoble's user avatar
  • 26.4k
4 votes
Accepted

How to change make command

why is stderr redirected to stdin, In order to have both end up in the quickfix list. what is that second command with tee doing, man tee. It redirects stdin into a file and into stdout. It's ...
Luc Hermitte's user avatar
  • 17.4k

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