On 16/07/11 21:57, Jakson Alves de Aquino wrote:
On Sat, Jul 16, 2011 at 4:38 PM, Tony Mechelynck
<[email protected]>  wrote:
[...]
However, I wonder whether this default could be changed to R
because, at least in Linux systems, it seems that there are far more R
users than Rexx users:
[...]

Always comment your sources abundantly. It makes them more human-readable,
and in this case it helps Vim determine the filetype: if there is a line
whose first nonspace character is # Vim treats it as r, if there is a line
whose first two nonspace characters are /* Vim treats it as rexx. This is
done in one loop, testing all lines in turn for both possibilities until one
is found or the end-of-file is reached. Since Rebol is easiest to determine
(and is done first), this leaves only uncommented r and rexx sources for the
fallback.

Your suggestion is good for existing scripts, but the problem would
remain for new files which when created are identified as Rexx. I
maintain a plugin which includes a ftdetect/r.vim script that makes R
to be the default, but R users who don't know about the plugin may
think that Vim doesn't have syntax highlight for R if they start to
edit a newly created file saved with .R extension.

Best regards,

Jakson Aquino


Hm, yes, when starting an empty file, there is of course nothing in it, so the default behaviour applies. The following workarounds are possible:

either:
        :e newfile.r
        :setlocal ft=r

or:
        :e newfile.r
                add a header comment
        :up
        :e

The first method _tells_ Vim what the filetype will be. The second one asks Vim to reload the file (:up = save changes if any; :e [with no filename] = reload the current file); this will re-evaluate the filetype, and now that the file contains a comment the detection will be correct.

But it seems that it might be useful to have a "user-specific" default for *.r files, like those which exist for some other extensions, see :help filetype-overrule

Bram, what do you think?


Best regards,
Tony.
--
For every complex problem, there is a solution that is simple, neat,
and wrong.
                -- H. L. Mencken

--
You received this message from the "vim_dev" 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

Raspunde prin e-mail lui