Saturday, December 31, 2011

Re: why is Vim coloring text in txt files?

On 31/12/11 18:18, wolfv wrote:
>
>
> On Dec 27, 12:55 am, Tony Mechelynck<antoine.mechely...@gmail.com>
> wrote:
>> /vimfiles/filetype.vim
>>
>> " filetype detection script (user customizations)
>> " I'll say this once only
>> if exists("did_load_filetypes")
>> finish
>> endif
>>
>> " allow continuation lines
>> let s:cpo =&cpo
>> set cpo&vim
>>
>> augroup filetypedetect
>>
>> " text files
>> au BufRead,BufNewFile
>> \ *.txt,README*,LISEZMOI*,LIESMICH*,LEESMIJ*
>> \ setf text
>>
>> " add additional filetype detection autocommands above this line
>> augroup END
>> let&cpo = s:cpo
> Hi Tony. After using Vim some more I noticed that my txt files wrap
> at column 80.
>
> My vimrc file has:
> setlocal lines=72 columns=100
>
> I copied the above filetype.vim file:
>
> When I have no filetype, files wrap at column 100 as desired. How to
> make txt files wrap at column 100?
>
> Thanks,
> wolfv
>

add a file $HOME/vimfiles/after/ftplugin/text.vim (for Windows) or
$HOME/.vim/after/ftplugin/text.vim (for Unix) (in either case, create
missing directories, if any, as you go).

In that file, either the following commands:

setlocal wm=0
let &l:tw = &columns

to break lines at the screen width current when the file is opened, or

setlocal tw=0 wm=0 wrap

not to break lines at all ("file lines" longer than the screen width
will be wrapped onto several "screen lines" but with no insertion of any
end-of-line marker).

See also the 'linebreak' option if you want the wrap to happen between
words but not break lines in the file.


:help 'wrapmargin'
:help 'textwidth'
:help 'wrap'
:help 'linebreak'
:help after-directory

and about the latter, I don't agree when the help says that it is
"rarely needed".


Alternatively, if your vimrc invokes the vimrc_example.vim, or if it was
copied from the version on the vimrc_example.vim which was current when
you first installed Vim, you have an autocommand: see
$VIMRUNTIME/vimrc_example.vim lines 69-70:

" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78

DO NOT modify the vimrc_example.vim (any upgrade may silently replace
it). If that autocommand was copied into your vimrc, you may remove it
there. Otherwise, immediately after the line which invokes the
vimrc_example.vim (with a :source or :runtime statement), add

au! vimrcEx FileType text

to remove that autocommand.


Best regards,
Tony.
--
Serocki's Stricture:
Marriage is always a bachelor's last option.

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

No comments:

Post a Comment