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

4
  • By "VIM bundle", - do you mean Pathogen? And, yes; it is still ~/.vim/after.
    – Runium
    Commented Jan 27, 2015 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
    Commented Jan 27, 2015 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
    Commented Jan 28, 2015 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
    Commented Jan 29, 2015 at 0:51

2 Answers 2

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

2
  • autocmd etc didn't change anything, sorry
    – user31220
    Commented Jan 28, 2015 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 Commented Nov 22, 2016 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .