Why does formatoptions flag "l" keep getting set with .conf files?

105 views
Skip to first unread message

Jeffery

unread,
Jul 2, 2009, 3:28:38 PM7/2/09
to vim_use
The formatoptions=tcql when I open .conf files. The "l" is the
problem. From the vim online help:

<screen scrape>
"l" Only break a line if it was not longer than 'textwidth' when the
insert
started.
</screen scrape>

This is kind of annoying, and I want it to stop. I verified it does
this on .conf files but not on .sh files, for example.

The default formatoptions=tcq (from vim online help), and using
the :set command seems to confirm this.

I tried adding the line "set formatoptions-=l" to my .vimrc, but it
did not work.

Here is the entirety of conf.vim. I do not see where is might be
messing with the formatoptions flags. At this point, I'm mystified
enough to post this query here.

<screen scrape>
" Vim syntax file
" Language: generic configure file
" Maintainer: Bram Moolenaar <Br...@vim.org>
" Last Change: 2005 Jun 20

" Quit when a (custom) syntax file was already loaded
if exists("b:current_syntax")
finish
endif

syn keyword confTodo contained TODO FIXME XXX
" Avoid matching "text#text", used in /etc/disktab and /etc/gettytab
syn match confComment "^#.*" contains=confTodo
syn match confComment "\s#.*"ms=s+1 contains=confTodo
syn region confString start=+"+ skip=+\\\\\|\\"+ end=+"+
oneline
syn region confString start=+'+ skip=+\\\\\|\\'+ end=+'+
oneline

" Define the default highlighting.
" Only used when an item doesn't have highlighting yet
hi def link confComment Comment
hi def link confTodo Todo
hi def link confString String

let b:current_syntax = "conf"

" vim: ts=8 sw=2
</screen scrape>


FYI, vim version:

<screen scrape>
$ vim --version
VIM - Vi IMproved 7.0 (2006 May 7, compiled Nov 5 2008 11:07:46)
Included patches: 1, 3-4, 7-9, 11, 13-17, 19-26, 29-31, 34-44, 47,
50-56, 58-64, 66-73, 75, 77-92, 94-107, 109, 202, 234-235, 237
Modified by <bugz...@redhat.com>
Compiled by <bugz...@redhat.com>
Huge version without GUI. Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset
+cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info
+comments
+cryptv +cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic
+emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path
+find_in_path
+folding -footer +fork() +gettext -hangul_input +iconv +insert_expand
+jumplist
+keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap
+menu
+mksession +modify_fname +mouse -mouseshape +mouse_dec +mouse_gpm
-mouse_jsbterm +mouse_netterm +mouse_xterm +multi_byte +multi_lang -
mzscheme
-netbeans_intg -osfiletype +path_extra +perl +postscript +printer
+profile
+python +quickfix +reltime +rightleft -ruby +scrollbind +signs
+smartindent
-sniff +statusline -sun_workshop +syntax +tag_binary +tag_old_static
-tag_any_white -tcl +terminfo +termresponse +textobjects +title -
toolbar
+user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace
+wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
-xterm_clipboard -xterm_save
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-
buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-D_FORTIFY_SOURCE=2 -D_REENTRANT -D_GNU_SOURCE -Wdeclaration-after-
statement -I/usr/local/include -D_LARGEFILE_SOURCE -
D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -I/usr/lib64/perl5/5.8.8/
x86_64-linux-thread-multi/CORE -I/usr/include/python2.4 -pthread
Linking: gcc -Wl,-E -Wl,-rpath,/usr/lib64/perl5/5.8.8/x86_64-linux-
thread-multi/CORE -L/usr/local/lib -o vim -ltermcap -
lselinux -lacl -lgpm -Wl,-E -Wl,-rpath,/usr/lib64/perl5/5.8.8/
x86_64-linux-thread-multi/CORE /usr/lib64/perl5/5.8.8/x86_64-linux-
thread-multi/auto/DynaLoader/DynaLoader.a -L/usr/lib64/perl5/5.8.8/
x86_64-linux-thread-multi/CORE -lperl -lresolv -lutil -lc -L/usr/lib64/
python2.4/config -lpython2.4 -lutil -lm -Xlinker -export-dynamic
</screen scrape>

_sc_

unread,
Jul 2, 2009, 4:57:56 PM7/2/09
to vim...@googlegroups.com

a suggestion and a question -- first the suggestion:

try :verbose set fo?

and see if it can tell you where the errant fo is being set

and the question: i see you are using an older vim, which implies
you are also using an older netrw -- in older netrws there was a
problem with it altering formatoptions for buffers in the same
session -- did you in fact use netrw to find and open your conf
file?

sc

Jeffery

unread,
Jul 2, 2009, 5:29:11 PM7/2/09
to vim_use
The :verbose output.

<screen scrape>
formatoptions=tcql
Last set from /usr/share/vim/vim70/scripts.vim
</screen scrape>

Thanks! That sure looks like a solid hint.


About netrw. I had to google what "netrw" was. I am fairly certain
I'm not using it assuming we're talking about this: http://freshmeat.net/projects/netrw/

I use putty from Windoze to ssh into my RHEL box from which I run vim.

Thanks for the tips, sc. Great info. I never know about :verbose
before.



On Jul 2, 3:57 pm, _sc_ <tooth...@swbell.net> wrote:
> On Thursday 02 July 2009 2:28 pm, Jeffery wrote:
>
>
>
>
>
> > The formatoptions=tcql when I open .conf files.  The "l" is the
> > problem.  From the vim online help:
>
> > <screen scrape>
> > "l"  Only break a line if it was not longer than 'textwidth' when the
> > insert
> >      started.
> > </screen scrape>
>
> > This is kind of annoying, and I want it to stop.  I verified it does
> > this on .conf files but not on .sh files, for example.
>
> > The default formatoptions=tcq (from vim online help), and using
> > the :set command seems to confirm this.
>
> > I tried adding the line "set formatoptions-=l" to my .vimrc, but it
> > did not work.
>
> > Here is the entirety of conf.vim.  I do not see where is might be
> > messing with the formatoptions flags.  At this point, I'm mystified
> > enough to post this query here.
>
> > <screen scrape>
> > " Vim syntax file
> > " Language:     generic configure file
> > " Maintainer:   Bram Moolenaar <B...@vim.org>

_sc_

unread,
Jul 2, 2009, 6:01:02 PM7/2/09
to vim...@googlegroups.com
On Thursday 02 July 2009 4:29 pm, Jeffery wrote:
>
> The :verbose output.
>
> <screen scrape>
> formatoptions=tcql
> Last set from /usr/share/vim/vim70/scripts.vim
> </screen scrape>
>
> Thanks! That sure looks like a solid hint.
>
>
> About netrw. I had to google what "netrw" was. I am fairly
> certain I'm not using it assuming we're talking about this:
> http://freshmeat.net/projects/netrw/

no, i was referring to the netrw.vim in your runtime/plugin
directory which you might use with :Explore or :e .

if you're not using it forget the warning and focus on scripts.vim

if you didn't know about :verbose, maybe you didn't also know about
the :scriptnames command, which will list all scripts invoked for
the current buffer -- also can be useful in debugging

anyway, glad to help -- vim on!

sc


risingjoker

unread,
Jul 2, 2009, 4:34:35 PM7/2/09
to vim...@googlegroups.com
Jeffery wrote:

> I tried adding the line "set formatoptions-=l" to my .vimrc, but it
> did not work.
>
> Here is the entirety of conf.vim. I do not see where is might be
> messing with the formatoptions flags. At this point, I'm mystified
> enough to post this query here.

create a directory ~/.vim/after/ftdetect
create a file in that directory named conf.vim
put you set command inside

Ben Fritz

unread,
Jul 2, 2009, 10:47:14 PM7/2/09
to vim_use


On Jul 2, 3:34 pm, risingjoker <risingjo...@gmail.com> wrote:
> create a directory ~/.vim/after/ftdetect
> create a file in that directory named conf.vim
> put you set command inside

A better place would be in the after/ftplugin directory. I'm pretty
certain the formatoptions are being modified in the ftplugin for conf
files, NOT the syntax file.

The OP mentioned checking the syntax file. You want conf.vim in the
ftplugin directory, not the syntax directory.

Charles E Campbell Jr

unread,
Jul 2, 2009, 11:48:14 PM7/2/09
to vim...@googlegroups.com

In fact, most/all of the ftplugin files in vim72/ftplugin change the
formatoptions variable
either to croql or add those options in (ie. set fo+=croql). Some
subtract the "t" option.
Several of the vim72/indent files do, too. So if you have the following
in your .vimrc:

filetype plugin indent on

then it'll likely change your formatoptions on you. In particular,
vim72/ftplugin/conf.vim has

setlocal comments=:# commentstring=#\ %s formatoptions-=t
formatoptions+=croql

The only syntax file I found (by a few searches, so there may be more)
that changes the
formatoptions setting is vim72/syntax/lpc.vim .

Regards,
Chip Campbell

risingjoker

unread,
Jul 3, 2009, 3:24:23 AM7/3/09
to vim...@googlegroups.com
Ben Fritz wrote:
>
>
> On Jul 2, 3:34 pm, risingjoker <risingjo...@gmail.com> wrote:
>> create a directory ~/.vim/after/ftdetect
>> create a file in that directory named conf.vim
>> put you set command inside
>
> A better place would be in the after/ftplugin directory. I'm pretty
> certain the formatoptions are being modified in the ftplugin for conf
> files, NOT the syntax file.

Thanks. Nice to know because I have some file configurations in that
place and now I need to move them.

Tony Mechelynck

unread,
Jul 5, 2009, 11:31:35 PM7/5/09
to vim...@googlegroups.com

The ftdetect directory is meant to contain scripts to be sourced by
filetype.vim, i.e., usually once per session when you do ":filetype
[plugin] [indent] on", to set up BufReadPost,BufNewFile autocommands for
filetype-detection. You could put those same autocommands in
~/.vim/filetype.vim but the idea of separate scripts is to make them
easier to drop when distributing a series of scripts to support a new
filetype (let's say "foobar") by means of, let's say, a
filetype-detection script ~/.vim/ftdetect/foobar.vim, a filetype-plugin
~/.vim/ftplugin/foobar.vim, a syntax plugin ~/.vim/syntax/foobar.vim, an
indent plugin ~/.vim/indent/foobar.vim, and a helpfile
~/.vim/doc/pi-foobar.txt, maybe all packed together as a compressed
vimball in .vba.gz format.


Best regards,
Tony.
--
If God had wanted you to go around nude, He would have given you bigger
hands.

Reply all
Reply to author
Forward
0 new messages