How do I make a file not be recognized as a file type?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I make a file not be recognized as a file type?

Sam Roberts
Specifically, I want to *.json to not be recognized as javascript
(because it isn't).

Other than hacking my system's definitions, what are my ways?

Should I be adding a before/... type override? something in .vimrc?

Thanks,
Sam

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I make a file not be recognized as a file type?

Charles Campbell
Sam Roberts wrote:
> Specifically, I want to *.json to not be recognized as javascript
> (because it isn't).
>
> Other than hacking my system's definitions, what are my ways?
>
> Should I be adding a before/... type override? something in .vimrc?
>
Do you have a comment character?  Use modelines.  Assuming % kicks off a
comment, put the following at the bottom of the file:

% vim: ft=

Regards,
C Campbell

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I make a file not be recognized as a file type?

Sam Roberts
On Fri, Oct 25, 2013 at 10:46 AM, Charles Campbell
<[hidden email]> wrote:
> Do you have a comment character?  Use modelines.  Assuming % kicks off a
> comment, put the following at the bottom of the file:

json does not, infamously, support comments

But even if it did, I want ALL *.json to be not recognized as javascript.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I make a file not be recognized as a file type?

Paul Isambert
Sam Roberts <[hidden email]> a écrit:
> On Fri, Oct 25, 2013 at 10:46 AM, Charles Campbell
> <[hidden email]> wrote:
> > Do you have a comment character?  Use modelines.  Assuming % kicks off a
> > comment, put the following at the bottom of the file:
>
> json does not, infamously, support comments
>
> But even if it did, I want ALL *.json to be not recognized as javascript.

Delete the autocommand defined in filetype.vim:

    :au! filetypedetect BufNewFile,BufRead *.json

Best,
Paul

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I make a file not be recognized as a file type?

Charles E Campbell Jr
Paul Isambert wrote:

> Sam Roberts <[hidden email]> a écrit:
>> On Fri, Oct 25, 2013 at 10:46 AM, Charles Campbell
>> <[hidden email]> wrote:
>>> Do you have a comment character?  Use modelines.  Assuming % kicks off a
>>> comment, put the following at the bottom of the file:
>> json does not, infamously, support comments
>>
>> But even if it did, I want ALL *.json to be not recognized as javascript.
> Delete the autocommand defined in filetype.vim:
>
>      :au! filetypedetect BufNewFile,BufRead *.json
>
Modifying a file such as filetype.vim that came with vim (ie. a system
file) is a Bad Idea.  After the next update, the changes (long
forgotten) will "disappear".

I was thinking that you wanted to change only "some" json files.  To do
all *.json files:

In your $HOME/.vim/filetype.vim (create it if you don't have one): put
in the following line,

  au BufNewFile,BufReadPost *.json   setl ft=

This command will override the system-assigned filetype of json with:
nothing!

Regards,
Chip Campbell


--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I make a file not be recognized as a file type?

Nikolay Aleksandrovich Pavlov


On Oct 28, 2013 7:14 PM, "Charles E Campbell" <[hidden email]> wrote:
>
> Paul Isambert wrote:
>>
>> Sam Roberts <[hidden email]> a écrit:
>>>
>>> On Fri, Oct 25, 2013 at 10:46 AM, Charles Campbell
>>> <[hidden email]> wrote:
>>>>
>>>> Do you have a comment character?  Use modelines.  Assuming % kicks off a
>>>> comment, put the following at the bottom of the file:
>>>
>>> json does not, infamously, support comments
>>>
>>> But even if it did, I want ALL *.json to be not recognized as javascript.
>>
>> Delete the autocommand defined in filetype.vim:
>>
>>      :au! filetypedetect BufNewFile,BufRead *.json
>>
> Modifying a file such as filetype.vim that came with vim (ie. a system file) is a Bad Idea.  After the next update, the changes (long forgotten) will "disappear".

There is no such :au***bang*** command in filetype.vim. Suggested method was removing the autocommand from vim in-memory structures.

> I was thinking that you wanted to change only "some" json files.  To do all *.json files:
>
> In your $HOME/.vim/filetype.vim (create it if you don't have one): put in the following line,
>
>  au BufNewFile,BufReadPost *.json   setl ft=
>
> This command will override the system-assigned filetype of json with: nothing!
>
> Regards,
> Chip Campbell
>
>
>
> --
> --
> 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
>
> --- You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.

--
--
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
 
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I make a file not be recognized as a file type?

Charles E Campbell Jr
Nikolay Pavlov wrote:

>
>
> On Oct 28, 2013 7:14 PM, "Charles E Campbell"
> <[hidden email] <mailto:[hidden email]>> wrote:
> >
> > Paul Isambert wrote:
> >>
> >> Sam Roberts <[hidden email] <mailto:[hidden email]>> a écrit:
> >>>
> >>> On Fri, Oct 25, 2013 at 10:46 AM, Charles Campbell
> >>> <[hidden email] <mailto:[hidden email]>>
> wrote:
> >>>>
> >>>> Do you have a comment character?  Use modelines.  Assuming %
> kicks off a
> >>>> comment, put the following at the bottom of the file:
> >>>
> >>> json does not, infamously, support comments
> >>>
> >>> But even if it did, I want ALL *.json to be not recognized as
> javascript.
> >>
> >> Delete the autocommand defined in filetype.vim:
> >>
> >>      :au! filetypedetect BufNewFile,BufRead *.json
> >>
> > Modifying a file such as filetype.vim that came with vim (ie. a
> system file) is a Bad Idea.  After the next update, the changes (long
> forgotten) will "disappear".
>
> There is no such :au***bang*** command in filetype.vim. Suggested
> method was removing the autocommand from vim in-memory structures.
>
Yes, there is.  Try looking at [/usr/local/share/vim/]vim74/filetype.vim
line#968.  Suggested method involved removing the line from vim's
distribution file.  Bad Idea.

C Campbell

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I make a file not be recognized as a file type?

Nikolay Aleksandrovich Pavlov


On Oct 28, 2013 7:35 PM, "Charles E Campbell" <[hidden email]> wrote:
>
> Nikolay Pavlov wrote:
>>
>>
>>
>> On Oct 28, 2013 7:14 PM, "Charles E Campbell" <[hidden email] <mailto:[hidden email]>> wrote:
>> >
>> > Paul Isambert wrote:
>> >>
>> >> Sam Roberts <[hidden email] <mailto:[hidden email]>> a écrit:
>>
>> >>>
>> >>> On Fri, Oct 25, 2013 at 10:46 AM, Charles Campbell
>> >>> <[hidden email] <mailto:[hidden email]>> wrote:
>> >>>>
>> >>>> Do you have a comment character?  Use modelines.  Assuming % kicks off a
>> >>>> comment, put the following at the bottom of the file:
>> >>>
>> >>> json does not, infamously, support comments
>> >>>
>> >>> But even if it did, I want ALL *.json to be not recognized as javascript.
>> >>
>> >> Delete the autocommand defined in filetype.vim:
>> >>
>> >>      :au! filetypedetect BufNewFile,BufRead *.json
>> >>
>> > Modifying a file such as filetype.vim that came with vim (ie. a system file) is a Bad Idea.  After the next update, the changes (long forgotten) will "disappear".
>>
>> There is no such :au***bang*** command in filetype.vim. Suggested method was removing the autocommand from vim in-memory structures.
>>
> Yes, there is.  Try looking at [/usr/local/share/vim/]vim74/filetype.vim line#968.  Suggested method involved removing the line from vim's distribution file.  Bad Idea.
>

No, there is not. Reread the line, it suggests using banged version of autocommand to remove it. **Banged**. Line you are suggesting to look at contains **no** *banged* version. It also contains more then just *.json in a list of patterns. It does *not* contain string "filetypedetect" because it is specified at the top of the file with :augroup.

Suggested method is undefining autocommand *after it was defined*. It though lacks information about where it should be put (most likely after :filetype ... on command), but it does not involve editing filetype.vim.

> C Campbell
>
> --
> --
> 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
>
> --- You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.

--
--
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
 
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I make a file not be recognized as a file type?

Charles E Campbell Jr
Nikolay Pavlov wrote:

>
>
> On Oct 28, 2013 7:35 PM, "Charles E Campbell"
> <[hidden email] <mailto:[hidden email]>> wrote:
> >
> > Nikolay Pavlov wrote:
> >>
> >>
> >>
> >> On Oct 28, 2013 7:14 PM, "Charles E Campbell"
> <[hidden email] <mailto:[hidden email]>
> <mailto:[hidden email] <mailto:[hidden email]>>>
> wrote:
> >> >
> >> > Paul Isambert wrote:
> >> >>
> >> >> Sam Roberts <[hidden email] <mailto:[hidden email]>
> <mailto:[hidden email] <mailto:[hidden email]>>> a écrit:
> >>
> >> >>>
> >> >>> On Fri, Oct 25, 2013 at 10:46 AM, Charles Campbell
> >> >>> <[hidden email]
> <mailto:[hidden email]>
> <mailto:[hidden email]
> <mailto:[hidden email]>>> wrote:
> >> >>>>
> >> >>>> Do you have a comment character?  Use modelines.  Assuming %
> kicks off a
> >> >>>> comment, put the following at the bottom of the file:
> >> >>>
> >> >>> json does not, infamously, support comments
> >> >>>
> >> >>> But even if it did, I want ALL *.json to be not recognized as
> javascript.
> >> >>
> >> >> Delete the autocommand defined in filetype.vim:
> >> >>
> >> >>      :au! filetypedetect BufNewFile,BufRead *.json
> >> >>
> >> > Modifying a file such as filetype.vim that came with vim (ie. a
> system file) is a Bad Idea.  After the next update, the changes (long
> forgotten) will "disappear".
> >>
> >> There is no such :au***bang*** command in filetype.vim. Suggested
> method was removing the autocommand from vim in-memory structures.
> >>
> > Yes, there is.  Try looking at
> [/usr/local/share/vim/]vim74/filetype.vim line#968.  Suggested method
> involved removing the line from vim's distribution file.  Bad Idea.
> >
>
> No, there is not. Reread the line, it suggests using banged version of
> autocommand to remove it. **Banged**. Line you are suggesting to look
> at contains **no** *banged* version. It also contains more then just
> *.json in a list of patterns. It does *not* contain string
> "filetypedetect" because it is specified at the top of the file with
> :augroup.
>
> Suggested method is undefining autocommand *after it was defined*. It
> though lacks information about where it should be put (most likely
> after :filetype ... on command), but it does not involve editing
> filetype.vim.
>
>
The method that was suggested by Paul Isambert was to delete the line
setting up the json syntax recognition in the system file. Still a bad idea.

To reiterate, what I suggested was to _override_ -- which works without
any exclamation marks.  It works.  Tried it. Before I sent out my
response to the OP.
Repeat: create/edit a personal file, $HOME/.vim/filetype.vim .  Put in
it the following line:

  au BufNewFile,BufReadPost *.json   setl ft=

Getting rid of the filetypedetect autogroup would remove a lot of syntax
detection, not just the *.json files.

C Campbell

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I make a file not be recognized as a file type?

Gary Johnson-4
On 2013-10-28, Charles E Campbell wrote:

> Nikolay Pavlov wrote:
> >
> >On Oct 28, 2013 7:35 PM, "Charles E Campbell" wrote:
> >>
> >> Nikolay Pavlov wrote:
> >>>
> >>> On Oct 28, 2013 7:14 PM, "Charles E Campbell" wrote:
> >>> >
> >>> > Paul Isambert wrote:
> >>> >>
> >>> >> Sam Roberts a écrit:
> >>>
> >>> >>>
> >>> >>> On Fri, Oct 25, 2013 at 10:46 AM, Charles Campbell wrote:
> >>> >>>>
> >>> >>>> Do you have a comment character?  Use modelines.  Assuming
> >% kicks off a
> >>> >>>> comment, put the following at the bottom of the file:
> >>> >>>
> >>> >>> json does not, infamously, support comments
> >>> >>>
> >>> >>> But even if it did, I want ALL *.json to be not recognized
> >as javascript.
> >>> >>
> >>> >> Delete the autocommand defined in filetype.vim:
> >>> >>
> >>> >>      :au! filetypedetect BufNewFile,BufRead *.json
> >>> >>
> >>> > Modifying a file such as filetype.vim that came with vim (ie.
> >a system file) is a Bad Idea.  After the next update, the changes
> >(long forgotten) will "disappear".
> >>>
> >>> There is no such :au***bang*** command in filetype.vim.
> >Suggested method was removing the autocommand from vim in-memory
> >structures.
> >>>
> >> Yes, there is.  Try looking at
> >[/usr/local/share/vim/]vim74/filetype.vim line#968.  Suggested
> >method involved removing the line from vim's distribution file.
> >Bad Idea.
> >>
> >
> >No, there is not. Reread the line, it suggests using banged version
> >of autocommand to remove it. **Banged**. Line you are suggesting to
> >look at contains **no** *banged* version. It also contains more
> >then just *.json in a list of patterns. It does *not* contain
> >string "filetypedetect" because it is specified at the top of the
> >file with :augroup.
> >
> >Suggested method is undefining autocommand *after it was defined*.
> >It though lacks information about where it should be put (most
> >likely after :filetype ... on command), but it does not involve
> >editing filetype.vim.
> >
> >
> The method that was suggested by Paul Isambert was to delete the line
> setting up the json syntax recognition in the system file. Still a
> bad idea.

No, that wasn't his suggestion.  That's what I thought originally,
too, and had the same reaction as yours.  I almost wrote a reply,
but I was tired, so I put it off.  Then I suddenly realized, "Oh,
_that's_ what he meant!"

Paul's wording was unfortunately ambiguous:  "Delete the autocommand
defined in filetype.vim:"  I'm not even sure I can rephrase it
clearly.  He did not mean to delete the definition from the file; he
meant to delete the autocommand, not from the file, but that which
was defined in the file.

The definition of that autocommand in filetype.vim is (at line 971
in Vim version 7.4.41):

    au BufNewFile,BufRead *.js,*.javascript,*.es,*.jsx,*.json   setf javascript

Paul's suggestion is not to delete that line, but to execute this
line,

    :au! filetypedetect BufNewFile,BufRead *.json

presumably by putting in one's ~/.vimrc.  That will simply delete
the autocommand from Vim's list of autocommands.

To clarify (I hope):  Start Vim and execute:

    :au filetypedetect BufNewFile,BufRead *.json

You will see this:

    --- Auto-Commands ---
    filetypedetect  BufNewFile
        *.json    setf javascript
    filetypedetect  BufRead
        *.json    setf javascript

Now execute Paul's command,

    :au! filetypedetect BufNewFile,BufRead *.json

and repeat the first command above.  You will see only this.

    --- Auto-Commands ---

No more *.json autocommand.  No modification of
$VIMRUNTIME/filetype.vim necessary.

Regards,
Gary

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I make a file not be recognized as a file type?

Paul Isambert
----- Mail original -----

> De: "Gary Johnson" <[hidden email]>
> À: "vim use" <[hidden email]>
> Envoyé: Lundi 28 Octobre 2013 18:54:19
> Objet: Re: How do I make a file not be recognized as a file type?
>
> On 2013-10-28, Charles E Campbell wrote:
> > Nikolay Pavlov wrote:
> > >
> > >On Oct 28, 2013 7:35 PM, "Charles E Campbell" wrote:
> > >>
> > >> Nikolay Pavlov wrote:
> > >>>
> > >>> On Oct 28, 2013 7:14 PM, "Charles E Campbell" wrote:
> > >>> >
> > >>> > Paul Isambert wrote:
> > >>> >>
> > >>> >> Sam Roberts a écrit:
> > >>>
> > >>> >>>
> > >>> >>> On Fri, Oct 25, 2013 at 10:46 AM, Charles Campbell wrote:
> > >>> >>>>
> > >>> >>>> Do you have a comment character?  Use modelines.  Assuming
> > >% kicks off a
> > >>> >>>> comment, put the following at the bottom of the file:
> > >>> >>>
> > >>> >>> json does not, infamously, support comments
> > >>> >>>
> > >>> >>> But even if it did, I want ALL *.json to be not recognized
> > >as javascript.
> > >>> >>
> > >>> >> Delete the autocommand defined in filetype.vim:
> > >>> >>
> > >>> >>      :au! filetypedetect BufNewFile,BufRead *.json
> > >>> >>
> > >>> > Modifying a file such as filetype.vim that came with vim (ie.
> > >a system file) is a Bad Idea.  After the next update, the changes
> > >(long forgotten) will "disappear".
> > >>>
> > >>> There is no such :au***bang*** command in filetype.vim.
> > >Suggested method was removing the autocommand from vim in-memory
> > >structures.
> > >>>
> > >> Yes, there is.  Try looking at
> > >[/usr/local/share/vim/]vim74/filetype.vim line#968.  Suggested
> > >method involved removing the line from vim's distribution file.
> > >Bad Idea.
> > >>
> > >
> > >No, there is not. Reread the line, it suggests using banged
> > >version
> > >of autocommand to remove it. **Banged**. Line you are suggesting
> > >to
> > >look at contains **no** *banged* version. It also contains more
> > >then just *.json in a list of patterns. It does *not* contain
> > >string "filetypedetect" because it is specified at the top of the
> > >file with :augroup.
> > >
> > >Suggested method is undefining autocommand *after it was defined*.
> > >It though lacks information about where it should be put (most
> > >likely after :filetype ... on command), but it does not involve
> > >editing filetype.vim.
> > >
> > >
> > The method that was suggested by Paul Isambert was to delete the
> > line
> > setting up the json syntax recognition in the system file. Still a
> > bad idea.
>
> No, that wasn't his suggestion.  That's what I thought originally,
> too, and had the same reaction as yours.  I almost wrote a reply,
> but I was tired, so I put it off.  Then I suddenly realized, "Oh,
> _that's_ what he meant!"
>
> Paul's wording was unfortunately ambiguous:  "Delete the autocommand
> defined in filetype.vim:"  I'm not even sure I can rephrase it
> clearly.  He did not mean to delete the definition from the file; he
> meant to delete the autocommand, not from the file, but that which
> was defined in the file.

My suggestion was indeed to use ":au!" to remove the autocommand, and I used an ambiguous phrasing indeed that could be interpreted as "Delete the line in filetype.vim".

Peace, love, and happiness :)
Paul

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I make a file not be recognized as a file type?

Charles E Campbell Jr
Paul Isambert wrote:

> ----- Mail original -----
>> De: "Gary Johnson" <[hidden email]>
>> [snip]
>> No, that wasn't his suggestion.  That's what I thought originally,
>> too, and had the same reaction as yours.  I almost wrote a reply,
>> but I was tired, so I put it off.  Then I suddenly realized, "Oh,
>> _that's_ what he meant!"
>>
>> Paul's wording was unfortunately ambiguous:  "Delete the autocommand
>> defined in filetype.vim:"  I'm not even sure I can rephrase it
>> clearly.  He did not mean to delete the definition from the file; he
>> meant to delete the autocommand, not from the file, but that which
>> was defined in the file.
> My suggestion was indeed to use ":au!" to remove the autocommand, and I used an ambiguous phrasing indeed that could be interpreted as "Delete the line in filetype.vim".
>
OK, apologies to all.
C Campbell

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.