octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Identification string for Octave script detection in VIM


From: Júlio Hoffimann
Subject: Identification string for Octave script detection in VIM
Date: Sun, 15 Apr 2012 13:18:27 -0300

Dear all,

I've being contacting VIM developers to add Rik's octave.vim syntax to the official VIM distribution. The problem we face is that (as we all know) GNU Octave scripts tries to be as compatible as possible with MATLAB scripts, making the automatic filetype detection impossible.

In VIM, files are generally identified by extensions (*.m) and comment symbols (%), but both interpreters share the same patterns. Although Octave supports # and the shebang mechanism, it's not good practice use them if we are looking for portability.

I heard Perl and Prolog suffered from the same issue in the past because their file extension, the solution VIM developers had at that time was to add an additional variable to set the preference of the user on .vimrc. The problem with that approach is that some users programmed in both languages and have to set the configurations over and over again is not desired. Having said that, Bram (The Man - Creator of VIM) purposed define an identification string for Octave scripts such that in the end the following pseudo-code would apply when opening *.m files:

if (filename matches *.m)
  if (comment_symbol == '#' || script_last_line == '% OctScript')
    filetype=octave
  else
    filetype=matlab

1. What do you think?
2. Any proposals for the identification string?
3. `OctScript' is okay? I invented. :-)

Regards,
Júlio.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]