On Fri, 2 Jul 2010, Daniel D Jones wrote:

> Using Gvim under Gentoo Linux, if I open a file with a .txt extension, 
> Gvim sets the filetype to text and sets the appropriate word wrap, 
> etc. that I have configured.  But if I open Gvim, create a new buffer 
> with :tabnew and then save that as a file with a .txt extension, Gvim 
> doesn't set the filetype and I have to explicitly set it in order to 
> get the word wrap and other file settings I have configured.  Is there 
> a setting I'm missing to have Gvim automatically recognize the file 
> type when the file is named and saved, or is that not possible absent 
> some scripting?

Hmm.  So, after my last reply in the other fork of this thread, I 
concluded that there wouldn't be reason for a *.txt file to not be 
properly recognized.

Apparently, *.txt files are by default set up to be ft=asciidoc.  And 
indeed, new or existing, that's what I get for *.txt files, with both 
vim and gvim loading them normally, or running :tabnew, :save 
something.txt.  (I'm also using Gentoo.)  Do you have something else 
that sets all that up?  Or maybe it's a problem of ordering?

E.g. if you have in your .vimrc:

filetype on[...etc...]
[...]
au BufRead *.txt setf text

That would need to be reversed:

Since the filetype autocmds are defined first (via the :filetype 
command), they would take precedence (thus ft=asciidoc).  But if you add 
your :au before the :filetype, yours would win out.  (There's a full 
discussion of this somewhere in the help, I'm sure, but ordering 
regarding :au + :filetype specifically came up recently on vim_use.)

-- 
Best,
Ben

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

Reply via email to