On 20/07/09 14:33, fka...@googlemail.com wrote:
>
> Dear Tony,
>
> Let me first thank you for your reply.
>
>
>> IIUC, these lines are there so that when you start Vim as
>>
>>      gvim -S
>> or
>>      gvim -S mysession.vim
>>
>> the empty [No Name] buffer, which is there before Vim loads the session,
>> finally gets wiped out so that you don't get an additional blank window
>> in addition to your reloaded session.
>
> I checked what happens when the mentioned lines in the session file
> (see my original posting) are commented out: I got no additional empty
> blank window. Anyway what these lines may be good for: Skipping them
> has (!) an effect, namely: It removes the problem and applies the
> *.txt file type settings. Of course, these lines are always recreated
> by each :mksesseion...
>
>
>> A session file saves the options when you run ":mksession" and restores
>> then when you start "vim -S". _What_ is saved is governed by your
>> 'sessionoptions' setting.
>
> Yes, I use a quite limited setting already: set
> sessionoptions=buffers,curdir,winsize

Hm. Sure you haven't got "options"? Check it by

        :verbose set ssop?

>
>
>> I is quite possible to run a startup script _not_ created by
>> ":mksession" as a result of "vim -S". Here's my current ~/Session.vim
>
> True -- however, I sometimes use a lot of split windows, too, and
> entering them all manually would kind of remove the gain of sessions
> at all for me (besides the buffer-add commands).

My session has a lot of files but it doesn't change much over time so 
that that isn't a problem for me.

>
> So, I still wonder, how to create a working session file which does
> not eat up my *.txt settings partly...
>
> Since it is only one single line in the sesstion file I need to skip
> (silent exe 'bwipe ' . s:wipebuf) I wonder why this causes problems at
> all? Somehow it prevents the autocommand to set the file type to
> *.txt. I do not see any relation. Perhaps my autocommand in my vimrc
> (see original posting) is incorrect?
>
> Thank You!
>   Felix

Create a ~/.vim/filetype.vim (on Unix) or ~/vimfiles/filetype.vim (on 
Windows) with the following contents (assuming you run in 'nocompatible' 
mode, e.g. by virtue of having a vimrc):

-----8<----- start
if exists("did_load_filetypes")
   finish
endif
augroup filetypedetect

au BufRead,BufNewFile *.txt setf txt

augroup END
----->8----- end

Don't include the "start" and "end" lines, and if you have more 
filetypes to detect, add similar autocommands near the middle. Hooking 
the BufWinEnter autocommand is not necessary because 'filetype' is a 
buffer-local (not window-local) option.

Once you have that script, restart Vim, and if you have 
filetype-detection on, *.txt files will be detected as filetype "txt". 
Also, this will be made part of Vim's filetype-detection system and obey 
any ":filetype on" or ":filetype off" commands you might give in a 
running Vim.

Make sure you do detect filetypes: typing

        :filetype

(with no ":set" before and no arguments afterwards) will tell you. I 
can't understand why wiping or not wiping one temporary buffer could 
make a difference though.

I notice that vim has no ftplugin/txt.vim, syntax/txt.vim or 
indent/txt.vim. The vimrc_example has an autocommand for the "text" 
filetype but not for "txt". So it's your job to write those files if you 
need to set particular settings for *.txt files.

To set 'expandtab' for txt files only and not for other files, your 
ftplugin/txt.vim should contain

        setlocal expandtab

(not "set expandtab") in order not to clobber the global default for 
other files.



Best regards,
Tony.
-- 
"I can't complain, but sometimes I still do."
                -- Joe Walsh

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to