Loading ...
Sorry, an error occurred while loading the content.

Prolog filetype problem

Expand Messages
  • Gautier DI FOLCO
    Hi all, I write some code in Prolog and some code in Perl, the problem is that these two languages have the same extension, is their a mean to set the good
    Message 1 of 3 , Sep 30, 2012
    • 0 Attachment
      Hi all,

      I write some code in Prolog and some code in Perl, the problem is that these
      two languages have the same extension, is their a mean to set the good
      filetype not according to their extension, but according to the language
      highlighting that find the most tokens?

      For your help,
      In advance,
      Thanks.

      --
      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
    • Ben Fritz
      ... It looks like Vim will automatically detect prolog rather than Perl if the first non-blank line contains any of: 1. the word prolog 2. a prolog comment,
      Message 2 of 3 , Sep 30, 2012
      • 0 Attachment
        On Sunday, September 30, 2012 4:07:41 PM UTC-5, Gautier DI FOLCO wrote:
        > Hi all,
        >
        > I write some code in Prolog and some code in Perl, the problem is that these
        > two languages have the same extension, is their a mean to set the good
        > filetype not according to their extension, but according to the language
        >
        > highlighting that find the most tokens?
        >

        It looks like Vim will automatically detect prolog rather than Perl if the first non-blank line contains any of:

        1. the word "prolog"
        2. a prolog comment, % or /* ... */
        3. the prolog :- construct

        Otherwise, Vim detects Perl. So for existing files, just get into the habit of starting the file with a header comment and you'll be fine.

        I guess new files will always detect as Perl, but there's really not any way I can think of for Vim to detect in a general way what filetype a brand-new empty file should be. You could set up some BufNewFile autocmds based on project directory or something if you like for this.

        --
        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
      • Gautier DI FOLCO
        2012/9/30 Ben Fritz ... Clever, thank you. -- You received this message from the vim_use maillist. Do not top-post! Type your reply
        Message 3 of 3 , Oct 1, 2012
        • 0 Attachment
          2012/9/30 Ben Fritz <fritzophrenic@...>
          It looks like Vim will automatically detect prolog rather than Perl if the first non-blank line contains any of:

          1. the word "prolog"
          2. a prolog comment, % or /* ... */
          3. the prolog :- construct

          Otherwise, Vim detects Perl. So for existing files, just get into the habit of starting the file with a header comment and you'll be fine.

          I guess new files will always detect as Perl, but there's really not any way I can think of for Vim to detect in a general way what filetype a brand-new empty file should be. You could set up some BufNewFile autocmds based on project directory or something if you like for this.

          Clever, thank you.

          --
          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
        Your message has been successfully submitted and would be delivered to recipients shortly.