My thesis is made up of multiple tex files and I'm constantly flicking between them so I created a shell script, load_files.sh:
#!/bin/bash
vim file1.tex file2.txt, ..., fileN.tex
This works fine but unfortunately because of the complex multi-file structure VIM's spell check doesn't work properly. I found that the answer from @Dominik solved the problem (Vim spellcheck not always working in .tex file. Check region in Vim ). However I don't want to run that command manually everytime I open the files and I don't want to put it into my tex.vim file because it is only my thesis that has this problem. So I tried to use the -c and the + flag in the shell script but it doesn't work (Vim - how to run a command immediately when starting vim? and How can I open vim with a particular line number at the top?) but it doesn't work. Here's what I've changed the vim line ni the shell script to:
vim +"syntax spell toplevel" file1.tex file2.txt, ..., fileN.texvim -c "syntax spell toplevel" file1.tex file2.txt, ..., fileN.tex
They open the files fine but when I turn the spell checker on the problem isn't fixed. FYI, if I open the files normally and run :syntax spell toplevel then the spell checker works.
Here is my response to @Conner because it is too long for a comment:
Thank you @Conner for the help. Are you saying that when I use the -c flag the command is only run on the first file and not all the files? This is definitely the problem but the solutions you give aren't able to help.
- I stated in the question that I only wnted this change made to my thesis tex files and so did not want add the command to tex.vim.
If I create a local vimrc, say
.thesis_vimrcand use the-uflag then if I want my plugins then I need to copy ~/.vimrc to.thesis_vimrcand then addsyntax spell toplevelto it. Unfortunately Pathogen stops working (presumably because it needs all the plugins in that directory but I don't want to have multiple copies of all my plugins). I tried to source~/.vimrcwithin.thesis_vimrcwithso ~/.vimrcbut I get the same Pathogen error.I tried opening all the files and changing the spelling using
syntax spell topleveland then saved a new session usingmksession. When I open the saved session thesyntax spell toplevelis not changed.Finally I tried to use
modelinesto addingset modelineandset modelines=1to~/.vimrcand add% vim: syntax spell toplevelto the first line of the files but then when I open those files, go to the buffers and turn on the spell checker I get the following error:syntax=tex Error detected while processing modelines: line 1: E518: Unknown option: toplevel
Surely it can't be this complicated, can anyone help please?
