Establishing filetype for a class of documents

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

Establishing filetype for a class of documents

Eric Weir

Is it possible to associated a class of documents with an established filetype without relying on the extents associated with the filetype. Specifically, I would like to have documents that have no extent recognized as markdown filetype.

Thanks,
------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA  USA
[hidden email]




--
You received this message from the "vim_mac" 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
Reply | Threaded
Open this post in threaded view
|

Re: Establishing filetype for a class of documents

David Henderson
On 16 Jul 2011, at 07:39, Eric Weir wrote:

> Is it possible to associated a class of documents with an established filetype without relying on the extents associated with the filetype. Specifically, I would like to have documents that have no extent recognized as markdown filetype.

Try this <http://stackoverflow.com/questions/5487338/vim-set-filetype-txt-for-every-new-file-no-name> as a solution, substituting markdown for txt where appropriate.

David P Henderson
c: xxx.xxx.xxxx
--
"You can't have capitalism on the way up and socialism on the way down."
   -- Newt Gingrich

--
You received this message from the "vim_mac" 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
Reply | Threaded
Open this post in threaded view
|

Re: Establishing filetype for a class of documents

Eric Weir

On Jul 16, 2011, at 11:55 AM, David Patrick Henderson wrote:

>> Is it possible to associated a class of documents with an established filetype without relying on the extents associated with the filetype. Specifically, I would like to have documents that have no extent recognized as markdown filetype.
>
> Try this <http://stackoverflow.com/questions/5487338/vim-set-filetype-txt-for-every-new-file-no-name> as a solution, substituting markdown for txt where appropriate.

As I understand the solution generated there, and I do not fully, the filetype in question would be applied to *all* new files. I don't want that. I want the files created by a particular plugin to be recognized as markdown.

Elsewhere I can cause files to be recognized as markdown by appending one of the extents associated with the markdown filetype. I don't have that option with this plugin. There no way to force it to assign one of these extents. If I do so manually and then attempt to open the file in the plugin, it simply creates a new file with the same name but without the extent.

------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA  USA
[hidden email]




--
You received this message from the "vim_mac" 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
Reply | Threaded
Open this post in threaded view
|

Re: Establishing filetype for a class of documents

David Henderson
On 16 Jul 2011, at 09:32, Eric Weir wrote:

>
> On Jul 16, 2011, at 11:55 AM, David Patrick Henderson wrote:
>
>>> Is it possible to associated a class of documents with an established filetype without relying on the extents associated with the filetype. Specifically, I would like to have documents that have no extent recognized as markdown filetype.
>>
>> Try this <http://stackoverflow.com/questions/5487338/vim-set-filetype-txt-for-every-new-file-no-name> as a solution, substituting markdown for txt where appropriate.
>
> As I understand the solution generated there, and I do not fully, the filetype in question would be applied to *all* new files. I don't want that. I want the files created by a particular plugin to be recognized as markdown.
>
> Elsewhere I can cause files to be recognized as markdown by appending one of the extents associated with the markdown filetype. I don't have that option with this plugin. There no way to force it to assign one of these extents. If I do so manually and then attempt to open the file in the plugin, it simply creates a new file with the same name but without the extent.
>
More specifically, it makes files with no associated filetype as determined by vim be associated with whatever filetype one assigns. It will not affect files with vim associated extensions and filetypes. My reading of your request was that there no associated file extension and you desired to associated those files with markdown. Was that an incorrect interpretation?

David P Henderson
c: xxx.xxx.xxxx
--
"God was left out of the [US] Constitution but was furnished a front seat on the coins of the country."
    -- Mark Twain

--
You received this message from the "vim_mac" 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
Reply | Threaded
Open this post in threaded view
|

Re: Establishing filetype for a class of documents

Eric Weir

On Jul 16, 2011, at 5:16 PM, David Patrick Henderson wrote:

> On 16 Jul 2011, at 09:32, Eric Weir wrote:
>
>> On Jul 16, 2011, at 11:55 AM, David Patrick Henderson wrote:
>>
>>> Try this <http://stackoverflow.com/questions/5487338/vim-set-filetype-txt-for-every-new-file-no-name> as a solution, substituting markdown for txt where appropriate.
>>
>> As I understand the solution generated there, and I do not fully, the filetype in question would be applied to *all* new files. I don't want that. I want the files created by a particular plugin to be recognized as markdown.
>>
>> Elsewhere I can cause files to be recognized as markdown by appending one of the extents associated with the markdown filetype. I don't have that option with this plugin. There no way to force it to assign one of these extents. If I do so manually and then attempt to open the file in the plugin, it simply creates a new file with the same name but without the extent.
>>
>
> More specifically, it makes files with no associated filetype as determined by vim be associated with whatever filetype one assigns. It will not affect files with vim associated extensions and filetypes. My reading of your request was that there no associated file extension and you desired to associated those files with markdown. Was that an incorrect interpretation?

Thanks David.

Yes it was, and I'll have to go back and review the solution suggested at the link you provided. On your explanation it would seem to do what I want.

------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA  USA
[hidden email]




--
You received this message from the "vim_mac" 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
Reply | Threaded
Open this post in threaded view
|

Re: Establishing filetype for a class of documents

David Henderson
On 16 Jul 2011, at 15:09, Eric Weir wrote:

> Thanks David.
>
No, problem.

> Yes it was, and I'll have to go back and review the solution suggested at the link you provided. On your explanation it would seem to do what I want.

One thing to consider, some files even with extensions have no associated filetype in vim, like .txt. Here is the solution I tested in my vimrc:

autocmd BufEnter * if &filetype == "" | setlocal filetype=markdown | endif

It’s an auto command that executes upon entering a buffer of anything; then, it checks the filetype to see if it is empty; if the filetype is empty, then it sets the local buffer to filetype markdown; otherwise, nothing happens. So files with no vim associated filetype will be treated as markdown files by vim or they will be treated as the associated filetype, for instance, .c := c file, .html := html, etc. Hope, this helps further.


David P Henderson
c: xxx.xxx.xxxx
--
"The proper office of a friend is to side with you when you are in the wrong. Nearly anybody will side with you when you are in the right."
    -- Mark Twain

--
You received this message from the "vim_mac" 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
Reply | Threaded
Open this post in threaded view
|

Re: Establishing filetype for a class of documents

Ben Schmidt
In reply to this post by Eric Weir
On 17/07/11 12:39 AM, Eric Weir wrote:
> Is it possible to associated a class of documents with an established
> filetype without relying on the extents associated with the filetype.
> Specifically, I would like to have documents that have no extent
> recognized as markdown filetype.

:help new-filetype-scripts

should point you in the right direction.

Cheers,

Ben.



--
You received this message from the "vim_mac" 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
Reply | Threaded
Open this post in threaded view
|

Re: Establishing filetype for a class of documents

Eric Weir

On Jul 18, 2011, at 5:21 AM, Ben Schmidt wrote:

> :help new-filetype-scripts
>
> should point you in the right direction.

Thanks, Ben. Yes, that did help, but I needed help with it, too, which was forthcoming from Vim users way more knowledgeable that I am or ever will be. The combination did help me come up with a solution, though. I assigned the filetype using the path to the files, which are all in one directory.

Regards,
------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA  USA
[hidden email]




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