1

Since I've installed this VIM autosession manager (which does its job) syntax highlighting gets killed on the first buffer change after starting vim. I can restore it with

:syntax on

but I would prefer not to have to. Maybe there is something in ~/.vim/after I could set?

Side question: I use VIM bundle; is it still ~/.vim/after ?

(I don't know if this matters: All I ever need syntax highlighting for are tex and lilypond files)

thanks

edit: here's a selection from my .vimrc - possibly a lot of stuff is redundant in there.

syntax enable
call pathogen#infect()
nmap <Tab> :bnext<CR>
filetype plugin on
filetype indent on
let g:tex_flavor="latex"
autocmd BufEnter Makefile* :set filetype=make
autocmd BufWinEnter . loadview
filetype off
set runtimepath+=/usr/share/lilypond/2.16.2/vim/
filetype on
syntax on
filetype plugin on

  • By "VIM bundle", - do you mean Pathogen? And, yes; it is still ~/.vim/after. – Runium Jan 27 '15 at 18:42
  • Is your .vimrc file big? Would it be possible for you to post it here? The autosess plugin is simply a wrapper for the builtin :mksession, see :h mksession. It does not do much beside auto-save a session file and load it. Have tested it with tex and lilypond files and they all highlights fine here. – Runium Jan 27 '15 at 19:54
  • (see edit in original answer. sorry I am a forum noob) does it make a difference at where in the .vimrc the settings are? – user31220 Jan 28 '15 at 13:55
  • Yes, generally, the order can be significant. i added an answer as it became a bit long for comment. Note that if you want to message someone use @ followed by nick (unless it is beneath owner's question/answer - like me to you in this message.) This way the user get a inbox flag in status bar. – Runium Jan 29 '15 at 0:51
1

See if this helps; add these to your ~/.vimrc file:

filetype plugin indent on
syntax on

If you do not have a ~/.vimrc file, just create one:

vim ~/.vimrc

For an extreme approach you could try this suggested on the wiki:

Highlight from start of file

For the most accurate but slowest result, set the syntax synchronization method to fromstart. This can be done with an autocmd in your vimrc:

autocmd BufEnter * :syntax sync fromstart

  • autocmd etc didn't change anything, sorry – user31220 Jan 28 '15 at 16:08
  • autocmd worked for me - thanks! I narrowed the scope of the autocmd only to the type of file affected and reduced the amount of sync lines with autocmd BufEnter *.css :syntax sync minlines=100 – the_velour_fog Nov 22 '16 at 3:56
0

Inside the autosess.vim plugin file, in function AutoSessRestore() I have put the autocmd! in comments, whatever that did (Remove ALL autocommands for the current group? it seems to have removed other autocommands too?) I don't understand why this works (how/why should my .vimrc be sourced twice and why should that matter?), but (so far) it does. Thank you guys, I have learnt a lot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.