Hot answers tagged

29

I suppose you already have Vim installed in your operating system. Usually, the installation is very straightforward for every operating system. For Macs, we have MacVim, and AFAIK two options are available: Getting the correct MacVim version for your operating system in the project website, unzip the archive file and drag MacVim.app to your Applications ...


24

Sometime around 2017 (I think), Dr. Chip decided that base-vim should only support syntax highlighting for base-latex. It is necessary to add in support for syntax highlighting for things available in latex packages (such as amsmath, which is what provides the align environment). But this is very easy, and Dr. Chip includes syntax files for amsmath (and a ...


20

When using VimTeX, you can type ]] in insert mode to close the current environment.


11

I know it's against policy to answer commenting on other answers, but in this case -- given I lack the 50 reputation needed to comment directly on the relevant answer -- I think it's worth it. The function provided by Aditya functions perfectly for LaTeX, mutatis mutandis, except for one detail: often after beginning an environment, or a section, the very ...


11

there is an option for that, you just have to add let g:tex_comment_nospell=1 in your .vimrc. About the internals, this variable is used in the file /usr/share/vim/vim73/syntax/tex.vim in my installation. [Edit for older versions] Checking vim source tree in older versions, this variable appears from revision 1073, which is after vim 7.0 and 7.1. As ...


11

Recent versions of Vim have a new 'conceal text' function. The syntax highlighting file contains code to work with this feature. The conceal text function collapses a string of text into a single Unicode character. For example, it might visually substitute \beta with β. Vim provides substitutions for the following subscripts by default, replacing the ...


11

You could just write ó and tell latex which encoding you are using, such as \usepackage[utf8]{inputenc} you do not have to use the ascii markup for accents unless you want to.


11

Since you are using vim you can use :setlocal nobomb :wq see https://stackoverflow.com/questions/295472/how-do-i-remove-the-bom-character-from-my-xml-file


10

let g:Tex_GotoError=0 in your ~/.vimrc should do pretty much what you want.


10

I have encountered the same problem as the OP, and I found that it is caused by the neosnippet configuration, which contains the folloing lines: " For snippet_complete marker. if has('conceal') set conceallevel=2 concealcursor=i endif The neosnippet plugin probably uses the 'conceal' feature of vim for some of its autocompletion functions. The solution ...


9

Side note for anyone who ends up here looking for the same thing I am: To disable specific IMAPs, add trivial IMAP commands to the file ~/.vim/after/ftplugin/tex.vim (you may have to create it if it does not exist). For instance, " Undo some latex-suite macros call IMAP('()', '()', 'tex') call IMAP('{}', '{}', 'tex') call IMAP('[]', '[]', 'tex') call IMAP(...


9

It has been saved as utf-16 and so every other byte is 0 (often displayed as ^@ as @ has code 64 so zero is control-@) The only thing I know about vim is that it isn't emacs but in chat my backup vim expert suggests :set fileencoding=utf-8 :set encoding=utf-8


9

If you run gnuplot <basename>-gnuplottex-fig1.gnuplot, you'll see gnuplot's error message plot for [i=1:14] 'benchmarks/test.csv' u (\$0+1):i title ''.i.'00 kb' with linespoints ^ "texse-gnuplottex-fig1.gnuplot", line 16: invalid character \ gnuplot is stumbling over the \$. You don't need to escape the ...


9

You can use this in your vimrc to quickly switch the compiler to xelatex with \lx. Then use \ll to compile. function SetXeTex() let g:Tex_CompileRule_pdf = 'xelatex -aux-directory=F:/Vim/my_latex_doc/temp --synctex=-1 -src-specials -interaction=nonstopmode $*' endfunction map <Leader>lx :<C-U>call SetXeTex()<CR> If you want to set ...


8

You can force spell checking for tex documents by putting the following into .vim/after/ftplugin/tex.vim or .vim/after/ftplugin/tex/spelling.vim: set spelllang=en_gb spell Your approach to do it with modeline magic % vim: spell spelllang=en_gb should work too, but you need to explicitly enable modelines. (They can be a security issue.) To do so, put the ...


7

Here is a basic tutorial for a Unix-like system (tested on Debian GNU/Linux). Yes, one can use latexmk, arara, shell scripts, or editor functions to automate much of this, but I wanted to demonstrate the simplest way to write and compile a LaTeX file "by hand" in the terminal. Open Terminal emulator Enter a directory where you will create your files. Type ...


7

Normally, you should have {}<++>, where <++> is a placeholder where you can jump using Ctrl+J. It seems like the delimiters for placeholders have been replaced by {}. From the documentation of latexsuite, maybe you should verify the value of the variables Imap_PlaceHolderStart and Imap_PlaceHolderEnd to check whether these have respectively been ...


7

I've modified Latex-Box (excellent) folding in two ways: i) since I only like to fold sections (parts, chapters, etc), the abstract environment and frames (in beamer class) I've added a new variable g:LatexBox_folded_environments that controls which environments are folded ii) I changed the LatexBox_FoldText() to resemble Latex-Suite. You should save this ...


7

There are instructions on how to do this here. For master file called my_master.tex, create a file in either the same directory as your \input{}ed file or a directory anywhere above that one called: my_master.tex.latexmain Now typing <leader>ll will compile the master document of whichever .tex file you currently have on screen.


7

When TeX, in interactive mode, shows the ? prompt after an error, you have a few choices, but you should keep in mind that the first character you type determines the subsequent behavior: return means “ignore the error and proceed” s means “run showing future error messages without stopping except for requesting user input” r means “run showing future error ...


7

Check if the syntax highlighting rules are up to date. Those should be located under /usr/share/vim/vim80/syntax/tex.vim. In this file there should be a block name Standard Math Zones:. Below that you'll find some lines stating something like: call TexNewMathZone("A","displaymath",1) To this block add the environments you find missing. E.g., for align use: ...


6

I just tested this out and it appears the problem you are having is that after compilation the cursor is left in the document and not in the error list. Moving between windows can be done simply with CTRL-W CTRL-W (this moves to the 'next' window - there are more window switching keystrokes - look them up with :help CTRL-W). Once in the error window hitting ...


6

Checkout your vim setting of backspace via :set backspace?. If it doesn't contain start you should add this :set backspace+=start (help :h 'backspace') to get the expected behavior of vim-latex. Honestly, I think this should be noted somewhere in the vim-latex documentation or even set automatically by the plugin since it relies on it.


6

You could use the soul package. If you put \usepackage{xcolor} and \usepackage{soul} in your preamble, then you can simply use \hl{...} to highlight a piece of text. Code \documentclass{article} \usepackage{xcolor} \usepackage{soul} \begin{document} Nullam accumsan, dui vitae vehicula aliquet, libero ligula congue turpis, rutrum molestie ante nisl ac mi....


6

I think this is the expected behaviour in vim-latexsuite and it may just be a bug in the quickstart tutorial. If you want to change to get this \begin{eqnarray} \label{}<++> \end{eqnarray}<++> with the cursor in between the label brackets, you can define the following variable and then type eqnarray followed by F5. let g:Tex_Env_eqnarray = ...


6

A first approximation would be to indent every line starting with a lower case letter by 4 spaces so a regex replace s/^\s*([a-z])/ \1/ in sed or perl or emacs or vim (I assume:-) LaTeX doesn't even see any white space at start of line except in verbatim environments so it doesn't matter what indentation you use as far as LaTeX is concerned.


6

You can press return at the end, but in VIM you would typically "reformat" or "rewrap" a paragraph after and during writing. Typical commands to do so are: gq (see :help gq) gw (like gq but puts the cursor back where it started :set textwidth = 70 :set textwidth is something people use for automatic wrapping, and sometimes it appears in their vimrc or ...


6

This can most certainly be done in Vim. Let me first give you methods for your four bullet points. I have made them all to be the shortcus <leader>i (i for index). If you do not know about <leader> I have made a small explanation below. The explanation of the commands are give below, as well. A keystroke that index the current word: :nmap &...


6

I don't know about automatic folding, but you should comment your fold markers : %{{{ and %}}}, otherwise they will be read by TeX. Also, you can put your opening fold marker at the end of the \newcommand line, so as to have a title to your fold. Your code would then look like : \newcommand{\ime}[3]{%{{{ \newpage {\Large \textbf{#1}} \...


6

Turning my comment into an answer: The \ stands for your leader, which is a definable key in vim for special shortcuts. You can set your leader with let mapleader = "<leader>" in your vimrc with <leader> being a key (e.g. let mapleader = ","). The key sequence would then be <leader>ll in normal mode (e.g. ,ll).


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