On 2/2/06, Aditya Mahajan wrote: > I use (g)vim to edit both context and latex files. Unfortunately, both > of them usually have *.tex extension. This mean that detecting > filetype from extension is not possible, so one should look into the > contents of the file to see if it a context file or not. > > I am planning to submit a ftdetect for context to vim. Right now, I > check if the first six lines of the file contain any of > '\\start\|\\enablemode\|\\unprotect\|\\setvariables\|\\module\|\\usemodule' > and if so, set the filetype to context, otherwise it is set to tex > (that loads latex plugins). > > This works for my context writing style. I would like to know about > other people's preference. > > 1. Do you write some keyword unique to context in the first few lines > of the file. Should I also check the last few line lines.
\enableregime, \setupoutput Is \setup too general (will it recognize any LaTeX document)? I don't know how slow/fast the detection is since I only use short files, but if you check the last few lines, \stoptext (together with its international alternatives) isn't a bad idea. Also, if you check the last few lines: emacs users usually put some lines of code at the end to mark the document as being written in ConTeXt. > 2. Are there any other keywords that you will like to include. A keyword like set tex_preferred_dialect=latex/context :) and then if tex_preferred_dialect == context if the first few lines contain \documentclass or \documentstyle, declare it latex, otherwise ConTeXt else [your script]: if the first line contains % tex= or any keywords that Hans sent or if the first six lines contain the keywords you suggested (together with international alternatives) (don't take that suggestion too seriously) Mojca _______________________________________________ ntg-context mailing list email@example.com http://www.ntg.nl/mailman/listinfo/ntg-context