On 2010-07-02, 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?

Vim assumes that you want to determine the file type when a file is
opened or a new buffer is created, i.e., before you start viewing or
editing, not when you write the file.  In most cases, by the time
you write a file you've either already set the file type or you
don't care.

The easiest way to set the file type after writing a file is to
simply edit it again,

    :e

If you really want to automate this, you could put an autocommand
like this in your ~/.vimrc:

    au BufWrite * if &ft == '' | filetype detect | fi

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

Reply via email to