latex equation display in vim - vim

I recently use the vim to write the latex source. But I got a very strange problem. When I open a old .tex file with vim, the equation will not show as usual. For example, when I type $K$, it just display K unless I move cursor to the line of the equation. And this does not happen when I open a new .tex file. Can anyone help? Thank.

I think you see the effects of the conceal feature; the Tex syntax plugin uses that do shorten certain sequences for display. See :help tex-conceal for the full explanation of that feature.
If this annoys you, just disable concealing, e.g. via
:set conceallevel=0

Related

Vim folding breaks colorscheme [duplicate]

I'm using vim for LaTeX and I'm using latex-suite. It gives me nice syntax highlighting and folding, but in large files syntax highlighting gets "confused". If I open all folds, the syntax highlighting turns OK. I would like it to "just work" all the time though.
I seem to recall an option that would increase the number of lines that is used as basis for determining syntax highlighting but I cant find it.
I don't edit LaTeX, but perhaps you want ":syn sync fromstart"? Just be warned that this can significantly slow down Vim since it forces Vim to do syntax highlighting parsing for the whole file rather than a section of the file. See ::help :syn-sync".
Ctrl+L in normal mode forces a redraw and often fixes syntax colour problems.
zRzMzx (i.e., expand all folds, contract all folds, fold to show current line) sometimes fixes syntax highlighting problems related to folds
10 years later, this is still somehow an issue. Similarly as Jeromy, I suggest pressing zRzMzzza which stands for
open all folds
close all folds
open (toggle) the fold I'm on
center buffer on this line
It looks like we need to learn to live with this

Show tex section list in vim

I like to use vim for tex file editing.
My document is lengthy, so I hope to show a list of section or subsection and navigate by just typing enter on the section name.
Please let me know some good plug-in or setting.
I know taglist plug-in shows a method list when editing Java source code, but it does not work for tex file.
You only need the built-in :global command:
:g/\\.*section{/#
and, possibly, a simple custom mapping:
nnoremap <key> :g/\\.*section{/#<CR>:
type a line number followed by <CR> to jump to the desired line.
I found latex-box has the feature what I really want.
See this gist. Save it as a file $HOME/.ctags on UNIX or $HOME/ctags.cnf on Windows. It allows ctags to make references to everything interesting in LaTeX files.

GVIM : in /root/.vimrc i have ":colorscheme desert" which worked, but where would i have found this value if someone hadn't told me?

So in GVIM i changed the color-scheme to
desert
but i never understood how to find this line
:colorscheme desert
so i could place it in
/root/.vimrc
file.
where would i have found out about " :colorscheme desert " ?
You could read the help (it is quite long and very detailed)
:h
Opens up to the main help for vim. Under getting started you will see the following. You might have to scroll down a bit (Use Control+f to page down)
usr_toc.txt Table Of Contents
Getting Started
usr_01.txt About the manuals
usr_02.txt The first steps in Vim
usr_03.txt Moving around
usr_04.txt Making small changes
usr_05.txt Set your settings
usr_06.txt Using syntax highlighting
usr_07.txt Editing more than one file
usr_08.txt Splitting windows
usr_09.txt Using the GUI
usr_10.txt Making big changes
usr_11.txt Recovering from a crash
usr_12.txt Clever tricks
It seems the that usr_06.txt is related to syntax highlighting so that might be worth reading. So type :h usr_06.txt or <c-]> (Control+]) to jump to that file when your cursor is on top of it.
Once you are in there you can look at the table of contents again.
06.1 Switching it on
06.2 No or wrong colors?
06.3 Different colors
06.4 With colors or without colors
06.5 Printing with colors
06.6 Further reading
Different colors seems to be what you want. So type :h 06.3 (or <c-]>) and the first paragraph talks about changing the colorscheme.
Control+] jumps to a tag and is talked about in :h tagsrch.txt (And on the line "Jump to a subject" immediately as you open :h)
The help have an auto completion feature.
So you can type, :help color followed by Ctrl+d. You won't necessary find the good entry right of the bat but it should put you on the right track. It would have shown you a colorscheme option.
An alternative is to use :helpgrep. :helpgrep color should give you a list of help file wich contains the string color.
On Debian Linux, it's part of the the vim-runtime package and sits in /usr/share/vim/vim73/colors/desert.vim. You can list contents of this direcory for more options. I don't think they have hard-coded color schemes in vim itself, so vim help will not list them for you.
I suppose like most other vim plugins, customized color schemes can also be put in ~/.vim directory.

Vim Code Folding for Scilab

I've just recently started to use the folding functionality of vim and it's very helpful for the languages that it works really well for.
My issue lies in the way vim comments out the fold markers in scilab code. It defaults to
/*{{{*/ and /*}}}*/
which works great in languages like C, but is not actually a comment in scilab. I get a multiplication error when i try to run the code.
I've tried adding
autocmd FileType scilab set fmr=//{{{,//}}}
to my .vimrc file which doesn't quite do what I'd like. It results in
/*//{{{*/ and /*//}}}*/
which are still not comments. The code "folds" fine but becomes unusable. I could set up a macro to replace every instance of "/*" with "//", but that could have unintended consequences when applied globally to a file.
So the question is: how can i setup vim fold markers comments for scilab files such that it will not render the file unusable?
You do not add the comments to 'foldmarker' itself, there's the 'commentstring' option that influences how Vim surrounds the fold markers (when creating folds with zf). Try setting
:setlocal commentstring=//%s
for your scilab filetype. (Put the command in ~/.vim/after/ftplugin/scilab.vim to make it permanent.)
It sounds to me like vim doesn't understand how SciLab comments work. I'm not sure if vim comes with SciLab syntax logic these days, is syntax highlighted correctly in your SciLab files? If not, you can get the syntax file from here.
Is there a particular reason you want to use marks? They aren't actually needed. If you don't want vim to auto-fold by syntax or indentation level, you can still manually define folds with
:set foldmethod=manual
That lets you select a chunk of text in visual mode and make it into a fold with 'zf'. No marks required.
More info on various vim folding techniques here.

vim spell checking - comments only in LaTeX files

I use gvim to edit LaTex .tex file. I noticed that it checks spelling on the fly only for the commented text. If I have a mistake in a regular text - no underline. If I comment this text with % , the misspell is underlined immediately. What is wrong? Is there any strange option turned on?
The latex ft plugin conveniently defines this behaviour.
SpellChecker : Spell check text including LaTeX documents
Using latexmk, vim spell checking and vim latex-suite
There is an option that appears to come close:
:syntax spell [toplevel | notoplevel | default]
Update
Also
:he ft-tex-syntax
has very useful tidbits, like
Don't Want Spell Checking In Comments? ~
Some folks like to include things like source code in comments and so would
prefer that spell checking be disabled in comments in LaTeX files. To do
this, put the following in your <.vimrc>: >
let g:tex_comment_nospell= 1
You'll have to figure out whether you can use that/extrapolate from there
I had the same problem (VIM 7.3), but this post at the vim-latex-devel mailing list provided the clue. To get the spell checking working, I had to put
syntax spell toplevel
in my ~/.vimrc, but it has to be declared after
syntax enable
or
syntax on
for it to work.
I don't whether this is a crude hack and the intended solution, but I created a file called .vim/after/syntax/tex.vim
containing the single line:
syn match texText "\<\w\+\>" contains=#Spell
Now vim spell checks the normal text between the commands and the text passed as parameters, because you cannot differentiate them syntacticly:
\frametitle{TextToBeChecked}
\pgfuseimage{VariableNotToBeChecked}
Hence, it checks way too much in my preamble. But I have it located in another file, so I don't really care.
This problem often occurs when working with files which are included by a master document.
If you are opening a TeX file which will be included and does not contain a section, chapter, \begin{document}, ... you can mark it by adding %begin-include at the top of the file. This way vim recognizes the file content as being part of the texDocZone region, which enables spellchecking.
With %end-include you can set the end of the texDocZone.
This behavior seems not to be documented, but is described in the vim syntax file: https://github.com/vim/vim/blob/master/runtime/syntax/tex.vim
tl;dr: Add %begin-include to the top of your tex file.
I encountered the same problem -- the .tex file for the first chapter of my book spell checked normally, but the file for the second chapter would only spell check the comments. This apparently happens because vim isn't looking at enough lines of context and gets confused. Ingo Karkat's solution here fixed it for me. Specifically, I used:
syn sync maxlines=2000
syn sync minlines=500
in ~/.vim/after/syntax/tex.vim
tldr; don't put \section commands in your master .tex document
I made the same observation and I also would insist on "before, it worked and I didn't change anything".
Then I observed that this unwanted behaviour only occurred in .tex documents where I have a master.tex that includes chapters as separate chapterx.tex files. Moreover, everything works fine if all the \section definitions are in the chapterx.tex's and NOT in the master.tex.
Otherwise, as I think, the vim syntax and spell checking routines have a hard time determining in which region they are, cf. this question Vim spellcheck not always working in .tex file. Check region in Vim
I found the same problem, but a different solution to it. In some .tex files the spell-check was working as expected others not (documentclass{scrlttr2}). Only in the comments words were underlined ... So I compared the headers of one working and one not working .tex document. I found a surprisingly texblock, which were hindering the spell check in the document itself:
\usepackage{array}
\newenvironment{Conditio}
{\par\vspace{\abovedisplayskip}\noindent\begin{tabular}{>{$}l<{$} #{${}={}$} l}}
{\end{tabular}\par\vspace{\belowdisplayskip}}
And this code was only an "hangover" of a different juridical text, I edited before. Commenting it out, set the normal spell-check with high-lighted texts in the letter document. (MacVim 8.1 latex-suite macOS 10.13.6 vim-latex v1.10.0)
None of the answers here worked for me, but I could see if I typed syntax spell as a command in vim it would work.
It turns out it was because syntax wasn't being set for the tex filetype automatically, and I found the solution here.
vim only spell checking in TeX comments
Editing a LaTeX document with vim, I noticed it was only spell-checking comments. I fixed this
by add this to my ./vimrc:
autocmd FileType plaintex,tex,latex syntax spell toplevel

Resources