On Sat, 17 Sep 2011, Spiros Bousbouras wrote:
If you define a syntax for a buffer , move away and then return is the
syntax remembered or do all the syntax commands have to be executed
again? Some tests I did indicate it's the latter.
It should be the former.
Specifically (with simplifications) my .vimrc (on Linux) has
autocmd BufReadPost,BufNewFile *.myfile source ~/myfile.vim
and file ~/myfile.vim has
if exists("b:myfile")
finish
endif
let b:myfile = 1
syntax match special /special/
highlight special term=bold cterm=bold
Either the simplifications have eliminated something important (though I
don't know what) or something else on your system is interfering. The
way you've set it up isn't the way a typical filetype-related plugin
should be laid out (see: :help new-filetype ). The way you've coded it
will work, but it will get messy, quickly, if you want to add multiple
filetypes.
When I edit file.myfile the highlighting works correctly but if I
move away and return then there's no highlighting.
Does some plugin from your system set up some kind of autocmd on the
WinEnter, WinLeave, BufEnter, or BufLeave event(s)?
:au WinEnter,WinLeave,BufEnter,BufLeave
On my system, I see about a dozen BufEnter entries, but none that would
affect a *.myfile buffer. Two in the filetypedetect augroup, one in
FileExplorer, and the ones in no group are vimball-related. WinEnter
only lists an autocmd in the matchparen group.
Is there a way to make the syntax remembered or do the syntax and
highlight commands have to be (re)executed every time the buffer is
loaded ? If it's the latter then I find it a strange design choice
because it is almost certain that you want the same sort of syntax
highlighting every time you edit the same buffer so it's a waste of
time to execute again and again the syntax and highlight commands.
Right. That would be strange, which is why it's not the case.
Something else must not be working properly.
--
Best,
Ben
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php