What sets textwidth=78

173 views
Skip to first unread message

Graham Lawrence

unread,
Mar 16, 2015, 2:06:32 PM3/16/15
to vim...@googlegroups.com
Using Huge vim 7.4 with patch 1-473 on arch linux

One of the last entries in my .vimrc is
  set textwidth=0
which is occasionally overridden by some feature in vim that arbitrarily sets the textwidth to 78.

Most of the time this creates no problem, but when I happen to add text to a .vimrc mapping  that exceeds 78 characters, arbitrary line breaks are introduced into it, which matters a great deal.

Does anyone know what might do this?
--
Graham Lawrence

nekneknek...@gmail.com

unread,
Mar 16, 2015, 2:12:10 PM3/16/15
to vim...@googlegroups.com
:verbose set textwidth

itchyny

Elimar Riesebieter

unread,
Mar 16, 2015, 3:40:50 PM3/16/15
to vim...@googlegroups.com
* Graham Lawrence <gl0...@gmail.com> [2015-03-16 11:06 -0700]:
:help textwidth. grep your vimrc for tw.

Elimar
--
We all know Linux is great... it does infinite loops in 5 seconds.
-Linus Torvalds

porphyry5

unread,
Mar 18, 2015, 2:28:49 PM3/18/15
to vim...@googlegroups.com
On Monday, March 16, 2015 at 11:12:10 AM UTC-7, nekneknek...@gmail.com wrote:
> :verbose set textwidth
>
> itchyny

I thank you for your help, but all this shows me is the current setting of textwidth.

porphyry5

unread,
Mar 18, 2015, 2:42:13 PM3/18/15
to vim...@googlegroups.com
My .vimrc only has my setting of textwidth to 0, but as you mentioned vimrc I have also set /etc/vimrc to tw=0 as well. We shall see what happens, unfortunately this change to my tw setting is a random (and relatively infrequent) event. Time will tell, I guess.

However, I do not expect it to solve the problem, as my .vimrc will follow /etc/vimrc, and the real problem is that some part of vim arbitrarily changes this setting. Most of the time I can change and create long lines without incident, because tw is 0. But sometimes it is 78.

Ben Fritz

unread,
Mar 18, 2015, 3:18:46 PM3/18/15
to vim...@googlegroups.com
Wrong.

This shows the current setting, *AND WHAT SCRIPT MADE THAT SETTING HAPPEN*.

The next time you see a textwidth setting you don't want, run this command to see where it was set to that value.

Then it is easy to zap the bad setting. It would be much harder to prevent or overwrite the setting without knowing what is setting it in the first place.

My guess is you have a filetype plugin or autocmd firing. But I obviously have no way of knowing which one that might be on YOUR system.

Gary Johnson

unread,
Mar 18, 2015, 3:18:52 PM3/18/15
to vim...@googlegroups.com
On 2015-03-18, porphyry5 wrote:
> On Monday, March 16, 2015 at 12:40:50 PM UTC-7, riesebie wrote:
> > * Graham Lawrence [2015-03-16 11:06 -0700]:
When it is 78, execute

:verbose set tw?

That will show you where it was set to 78. I know you wrote in
another message that it did not show you where 'tw' was set, but I
suspect that you did not do that when 'tw' was 78.

Regards,
Gary

porphyry5

unread,
Mar 21, 2015, 11:57:30 AM3/21/15
to vim...@googlegroups.com
On Wednesday, March 18, 2015 at 12:18:46 PM UTC-7, Ben Fritz wrote:
> On Wednesday, March 18, 2015 at 1:28:49 PM UTC-5, porphyry5 wrote:
> > On Monday, March 16, 2015 at 11:12:10 AM UTC-7, nekneknek...@gmail.com wrote:
> > > :verbose set textwidth
> > >
> > > itchyny
> >
> > I thank you for your help, but all this shows me is the current setting of textwidth.
>
> Wrong.
>
> This shows the current setting, *AND WHAT SCRIPT MADE THAT SETTING HAPPEN*.

NOT ONE OF MINE. I have absolutely no interest in a limited textwidth under any circumstances.

>
> The next time you see a textwidth setting you don't want, run this command to see where it was set to that value.

Which command?

>
> Then it is easy to zap the bad setting. It would be much harder to prevent or overwrite the setting without knowing what is setting it in the first place.
>
> My guess is you have a filetype plugin or autocmd firing. But I obviously have no way of knowing which one that might be on YOUR system.

Here is the entirety of my .vimrc. All the set and autocommands are in a group at the end of it.
map __ :xa<CR>
" Directory and file access
map _D :e /mnt/1/Documents<CR>
map _E :e /mnt/1/Documents/Essays<CR>
map _H :e /home/g<CR>
map _J :e /mnt/1/Scripts/junk.sh<CR>
map _L :e /mnt/1/MyBooks/Programming/Linux<CR>
map _P :e /mnt/1/MyBooks/Pdfs<CR>
map _R :e /mnt/1/Redo<CR>
map _S :e /mnt/1/Scripts/<CR>
map _T :e /mnt/1/Scripts/test.sh<CR>
map _V :e ~/.vim/<CR>
" Convert .ass to .srt. Put cursor on start of line before 1st dialog line
map _as :normal dgg<CR>:%s/^[^,]*,/\r/<CR>:%s/,/ --> /<CR>:%s/,.*,,.*,,/\r/<CR>:%s/\\N/\r/g<CR>
map _b :buffers<CR>
" ConcatenateTitles and accumulate them in register z
map _c :call CapCon()<CR>:s/^\([0-9]*\)\(.*\)/\2\1/<CR>:normal "Zyy<Space>j<CR>
map _d /[A-Za-z]<CR>:normal d$mm<CR>:let @/=@"<CR>:normal n<CR>:call CapCon()<CR>:normal 0y$`mpj0<CR>
" Convert footnotes, {\d\+}, to html form
map _fn gg/{\d\+}<CR>"pyWx"qdwx:let @r='<a name="fn' . @q . '"></a><a href="#FN' . @q . '">' . @q . '</a>'<CR>"rP:let @/=@p<CR>//<CR>dW:let @r='<a name="FN' . @q . '"></a><a href="#fn' . @q . '">' . @q . '</a>'<CR>"rP;fn
" Fix common errors in ebook texts
map _ft :%s/ \([,.?!;:]\)/\1/g<CR>:%s/^\s\+\("[^"]\+\)\n\s*\([^"]\+"\)/\1 \2/c<CR>:%s/" "/"\r\t"/<CR>:%s/^\(["A-Z]\)/\t\1/<CR>:%s/^\s\+/\t/<CR>:%s/\. "/.\r\t"/g<CR>
" Convert invalid character codes
map _g :%s/\nâ\%x80\%xa0/ ++\r/ge<CR>:%s/â\%x80\%xa0/ ++/ge<CR>:%s/â\%x80¢/\*/ge<CR>:%s/Ë\%x86/\^/ge<CR>:%s/â\%x80\%x93/-/ge<CR>:%s/ï¬\%x82/fl/ge<CR>:%s/ï¬\%x81/fi/ge<CR>:%s/Ë\%x9c/\~/ge<CR>:%s/\%x80\%x99/'/ge<CR>:%s/\%x80\%x9c/"/ge<CR>:%s/\%x80\%x9d/"/ge<CR>:%s/\%x80"/ - /ge<CR>:%s/\%x80\%x98/'/ge<CR>:%s/\%x80\%x94/ -- /ge<CR>:%s/\%x80\%x93/-/ge<CR>:%s/â\%x86\%x90//ge<CR>:%s/â\%x86\%x92//ge<CR>:%s/â//ge<CR>:%s/\%x88\%x92/-/ge<CR>:%s/\%x88\%x9e\$\%x8a\%x88\%x9e//ge<CR>:%s/\([a-z]\)\- \([a-zA-Z]\)/\1\2/ge<CR>:%s/\- *\n *\([a-zA-Z]\)/\1/ge<CR>
map _G :%s/^$\n//ge<CR>:%s/([^)]*)//ge<CR>:%s/\[[^]]*\]//ge<CR>:%s/{[^}]*}//ge<CR>:%s/ [a-zA-Z0-9]\./ /ge<CR>:%s/^[a-zA-Z0-9]\. //ge<CR>:%s/ &[^;]*; / /ge<CR>:%s/[0-9]\+//ge<CR>:%s/(.*\n[^)]*)//e<CR>:%s/{.*\n[^}]*}//e<CR>:%s/\[.*\n[^]]*\]//e<CR>:%s/\s\+/\r/ge<CR>:%s/[Aa][Ee]lig/ae/ge<CR>:%s/[!?:"(){}\[\]\|<>\/;,.@#$%^&*_+=\-`\~\\]//ge<CR>:%s/^'//e<CR>:%s/'$//e<CR>:%s/[A-Z]/\l&/ge<CR>:sort u<CR>
" ;ht Converts essays to html. Does title, double spaces, <P> and </body></html. Do ;n on wf.txt first.
map _ht :%s/^$/<P>/e<CR>:%s/ / \&nbsp;/ge<CR>ggO<ESC>:let a = substitute(@%, "[^A-Za-z].*", "", "")<CR>:let b = substitute(a, '\([a-z]\)\([A-Z]\)', '\1 \2', "g")<CR>:let @m = '<h2 align="CENTER"><a name="' . b . '">' . b . '</a></h2>'<CR>"mPGo</body></html><ESC><CR>ggO<ESC><CR>:r wf.txt<CR>kdd<CR>
" ;hn Make heading and anchor, accumulate links in z. ;hn
map _hn /^Chapter <CR>wd0y$i<h3><a name="chapter<Esc>A">Chapter <Esc>pA</a></h3><Esc>j:let @Z=@z . '<a href="#chapter' . @" . '">Chapter ' . @" . '</a><br>'<CR>
map _hn :source ~/.vim/hn.vim<CR>
" Do chapter headings from each Chapter line and accumulate hrefs in register z
map _h3 /\tChapter \d\+<CR>xd2w:let @m='<h3><a name="' . @" . '">' . @" . '</a></h3>'<CR>"mPj:let @Z='<a href="#' . @" . '">' . @" . '</a><br>@'<CR>;h3
" Do chapter headings line by line from a Contents
map _h1 0EBy$:let @/=@"<CR>:let @q=@" . '">' . @" . '</a><'<CR>0c$<a href="#<Esc>"qpAbr><Esc>jmm//<CR>0c$<h3><a name="<Esc>"qpA/h3><Esc>'m
" Do Chapter headings line by line found in text by a search pattern
map _h2 0i<h3><a name='<Esc>ly$A'><Esc>pa<\/a><\/h3><Esc>:let @Z='<a href="#' . @" . '">' . @" . '<\/a>'<CR>
map _m :marks<CR>
" ;n Converts keywords in wf.txt to <META keywords and description ready to type. Run wf() first.
map _n :%s/^[0-9 ]\+//ge<CR>gg"myGgUG"ndG"mP:.,$s/\<[a-z]/\u&/ge<CR>"mP"nP:%s/\(.*\)\n/\1,/ge<CR>$xxa"></head><body><ESC>0i<META NAME="keywords" CONTENT="<ESC>O<html><head><META NAME="description" CONTENT="
" Remove empty lines and link numbers from most recent paste
map _p :'[,']s/\n\n/\r/<CR>:'[,']s/\[\d\+\]//g<CR>
" Fix page numbers and TOC in pdftotext output. MUST set marks a, b first
map _pt :'a,'bd<CR>:'c,'ds/[^A-Za-z0-9][^A-Za-z0-9][^A-Za-z0-9]\+/ /ge<CR>:'c,'ds/^ .*$\n//ge<CR>:'e,'fs/^ .*$\n//ge
":%s/†/"/ge<CR>:%s/“/"/ge<CR>
map _pu :'b,'cs/^\([0-9][0-9]\?\)\n\n\n\n\?\([A-Z].*\)/Chapter \1 \2/ce<CR>
map _pv :'b,'cs/^\%x0c\(Appendix [A-Z]\)\n\n\n\([A-Z].*\)/\r\1 \2/ce<CR>
" Close help window and restore textwidth to no limit
map _q :q<CR>:set textwidth=0<CR>
" Show contents of registers
map _r :reg<CR>
" Show cursor location in red, see also hi commands at end of this file
map _s :set cuc<CR>:set cul<CR>:sleep<CR>:set cuc!<CR>:set cul!<CR>
" standardize text before converting to epub, do chpter headings first
map _t :%s/^\s\+/\t/e<CR>:%s/" "/"\r\t"/ge<CR>:%s/' '/'\r\t'/ge<CR>:%s/\n\t\([a-z\-]\)/ \1/e<CR>:%s/\s\+$//e<CR>:%s/\([^.?!"']["']*\)\n\t\([^"']\)/\1 \2/ce<CR>
" Set up latest command to be appended to .vimrc
map _v 'VGo" <Return>" <Esc>":PkA
" Write current file and copy it to /mnt/1
map _w :w<CR>:exe "!cp % /mnt/1/%"<CR><CR>
" Paste sorted contents of register z above current line
map _zp :let @z = join(sort u(split(@z, "\n")), " ") . "\n"<CR>"zP<CR>:let @z = ""<CR>
" If number find next occurrence alone on its own line, if file path display it
map \\ :normal WB"myW<CR>:let c = stridx(@m, '.')<CR>:if c < 0<CR>:let a = '^' . substitute(@m, '^\s*\(.\{-}\)\s*$', '\1', '') . '$'<CR>:let l = search(a, 'esw')<CR>:normal zt<CR>:else<CR>:let @m = @m . " &"<CR>:exec "!xv" @m<CR>:endif<CR><CR>
" Arrow key mappings
map <A-right> <ESC>:bn<CR>
map <A-left> <ESC>:bp<CR>
map <DOWN> gj
map <UP> gk
imap <UP> <ESC>gki
imap <DOWN> <ESC>gji
" Look up help for current word/WORD
map <F1> <ESC>:exec "help ".expand("<cWORD>")<CR>
" Toggle line numbers
map <F2> :set nonumber!<CR>
" <F3> Toggle automatic indent for "pastes" <F3>
" Toggle text colorization
map <silent> <F4> :if exists("g:syntax_on")<CR>syntax off<CR>else<CR>syntax enable<CR>endif <CR>
"
" Ebook Error Correction Group
" search text for next error, if not found delete from y.sed and find next
map _9 :let v:errmsg = ""<CR>:silent! / z<CR>zz `m:if v:errmsg != ""<CR>:exe "norm dd<F6>"<CR>:endif<CR><CR>
" resume editing if vim shows y.sed
map <F5> 0ll"zyt/f/lmm'WG$"yp:.,$s/\\>.*//e<CR>'[:.,$s/^....//e<CR>'[dd:.,$s/^[A-Z].*\n//e<CR>:%s/^\s*$\n//e<CR> 'mqyq:split y<CR>_9:%s/.*[A-Z][a-z].*\n//c<CR>
" do not add to wd.s, do current line
map <F6> 0ll"zyt/f/lmm _9
" add to wd.s, do current line
map <F7> :let @Y=@"<CR><F6>
" fix concatenations, put cursor on first letter of concatenated word in y.sed line
map <F8> mm"qyF\`m"pyw:s/ p/\\(\[a\-z\]\\+\\)/e<CR>:s// \\1/e<CR>j:.,$s/.* q.*\n//e<CR>'m j
" whitespace from line ends, join lines if no sentence end, speech ending as ' -$' to ..."
map <F9> gg:%s/\([.?!] \)\([a-z]\)/\1\u\2/eg<CR>:%s/ \+$//e<CR>:%s/\("[^"]*\) \-$/\1..."/e<CR>:%s/\n\t\([a-z]\)/ \1/cge<CR>
" correct error by replacing '-' with ' - '
map <F10> $F-xi - <Esc>j<F6>
" Capitalize any sentence beginning with lower case letter
map _1 :%s/\([.?!]\) *\([a-z]\)/\1 \u\2/g<CR>
" Chapterize txt to html and chapterize lines that start with one or more upper case letters
map _2 :%s/\t/<p>/e<CR>:%s/^\([A-Z]\+\.* .*\)$/<h3>Chapter \1<\/h3>/ce<CR>
" End of ebook correction group
"
" Restore file marks in .viminfo
map _6 :e ~/.viminfo<CR>/^# File marks:<CR>:r /mnt/1/file.mks<CR>']j
map _8 :let @x=@x+1<CR>/<br><b>\d\+<\/b><CR>:s/\(<b>\d\+<\/b>\)/<a name='n x'>\1<\/a>\r<a href='#n x'>\1<\/a>\r/<CR>_8
" Remove search highlights
nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
" :Mn Join n lines and reformat as 'textwidth' character lines
com! -nargs=+ M call Join(<f-args>)
function! Join(a)
:s/^\s*/#/
:exe ':normal 0mm ' . a:a . 'JA <'
:normal xmn
:'m,'ns/\([a-z0-9]\)\- \([a-z0-9]\)/\1\2/ge
:'m,'ms/^#/ /
:'m,'ns/^# //e
:normal 'n$xjzz
endfunction
com! -nargs=1 H call Hn(<f-args>)
function! Hn(size)
exe ':s/\(.*\)/<H' . a:size . '><a name="\1">\1<\/a><\/H' . a:size . '>\r<a href="#\1">\1<\/a> \&nbsp;/'
endfunction
" :In Invert n lines to columns
com! -nargs=1 I call It(<f-args>)
"com! -nargs=+ I call It(<f-args>)
"function! It(l,c)
function! It(n)
let l=0
let a=[]
while l<n
let a[l] = '["' . substitute(strpart(getline('.'), 4), ' ', '","', 'g') . '"]'
normal dd
let l=l+1
endwh
let n=len(a[1])
let l=0
while l<n
b=

endfunction
" :Tn Strip unessential words the, a, an, is, are in each of n lines
com! -nargs=1 T call Tr(<f-args>)
function! Tr(l)
let n = a:l
while n > 0
s/\<[Tt]he //ge
s/\<[Aa]n\? //ge
s/\<is //ge
s/\<are //ge
s/[,.;:!?]$//ge
let n = n - 1
normal j0
endw
endfunction
function! Params()
let pars = input("Type your parameters, Tab separated, no quotes")
return(split(pars, "\t"))
endfunction
function! CapCon()
normal guu
exe ':s/\-/ /ge'
exe ':s/[^a-z ]//ge'
exe ':s/\<[a-z]/\u&/ge'
exe ':s/ //ge'
endfunction
function! Psrch()
set nopaste
return @/
endfunction
function! GetInp()
call inputsave()
let g:Inp = input("enter search pattern: ")
call inputrestore()
endfunction
function! DoAts()
while 0==0
norm "myWhma
let @n=substitute(@m, "[^a-zA-Z0-9'\-]", "", "g")
let @/='@@' . @n
%s//\=@n/ge
norm `a
redraw
let @/=@n
call GetInp()
if Inp == 'q'
let @o='qq' . @n
%s//\=@o/ge
else
let @Z=@n . ' '
en
norm `an
endw
endfunction
au! BufWritePost ~/.vimrc source % " reload .vimrc whenever updated
set nocompatible " vim default options
set autochdir " pwd is always directory of current buffer
set autoindent " auto indentation turned on as default
set autowriteall " automatically save file when switching buffers
set background=dark
set cmdheight=2 " Set the command window height to 2 lines, for overflow
set cwh=2
set confirm " prevent command failure due to unsaved changes to the file
set cpoptions+=> " Any addition to a register always terminated by one <CR>
set directory=.
filetype plugin indent on
set laststatus=2 " Always display the status line
set linebreak
set mouse=a " allow middle mouse pasting with Shift key held down, like MC
set notimeout ttimeout ttimeoutlen=200 "time out keycodes never mappings
set nrformats=alpha,octal,hex " enable ^A ^X on letters, digits, octal, hex
set pastetoggle=<F3>
set shiftwidth=2 " indent 2 character widths
set showcmd
set statusline=%F%M%R%H%W\ %{&ff}\ %Y\ hex=\%02.2B\ l=%04l,c=%04v,%p%%\ %L
set tabstop=2 " tab is 2 character widths
set viminfo='50,f1,<500,:50,@20,/20,!,%
set visualbell " xterm flashes text color on beep condition
set wildmenu " Better command-line completion
syntax on " Enable syntax highlighting
set hlsearch
set incsearch
set textwidth=0
hi CursorLine ctermbg=1
hi CursorColumn ctermbg=1



porphyry5

unread,
Mar 21, 2015, 12:12:17 PM3/21/15
to vim...@googlegroups.com, gary...@spocom.com
Thank you, by a happy coincidence it has occurred again, and
:verbose set tw?
reveals the culprit to be /usr/share/vim/vim74/ftplugin/vim.vim
maintained by one Bram Moolenaar
rather incontrovertibly proving my claim that this thing was set by vim itself.

Thank you again, its easy to fix.

Tim Chase

unread,
Mar 21, 2015, 12:12:25 PM3/21/15
to vim...@googlegroups.com, gl0...@gmail.com
On 2015-03-21 08:57, porphyry5 wrote:
>>>> :verbose set textwidth
>> The next time you see a textwidth setting you don't want, run
>> this command to see where it was set to that value.
>
> Which command?

The ":verbose set textwidth". Note the "verbose" as it's what
instructs Vim to tell you what last set it.

My guess is that it's some plugin/ftplugin that gets activated for
certain files, so your default is 'tw' being 0, but then the plugin
(which the ":verbose set" command above will identify) changes it to
78.

So recreate the scenario in which the tw=78 happens, then issue the
":verbose set" command to find out who the guilty plugin is.

-tim


Tim Chase

unread,
Mar 21, 2015, 2:03:49 PM3/21/15
to Graham Lawrence, vim_use
On 2015-03-21 10:20, Graham Lawrence wrote:
> Thanks for your response, it was hard to track down even with
> the :verbose ... command, because the condition occurs erratically,
> but it did happen this morning and the command revealed it was
> caused by /usr/share/vim/vim74/ftplugin/vim.vim, which I think can
> reasonably be regarded as a function of vim itself.
>
> I just use the standard package issued by arch, any additional
> functionality I want I write myself, and the last thing I would
> ever do is limit the line length.

My understanding based on what you give (modulo any Arch-specific
changes that aren't present on my Debian Stable box with 7.3 stock,
though I'd expect that Arch sticks much more to the native package
compared to the modifications that Debian likes to make to packages)
that

1) this should only happen when editing *.vim files or you manually

:set ft=vim

2) this setting should only persist in vim files since it
uses :setlocal rather than :set (which would persist across
newly-opened windows)

3) it checks if a 'tw' is already set and doesn't mess with it if
it's non-zero. Thus, you might be able to hack it with something
like

:set tw=2147483647 " the maximum line length for non-DOS vim

so that it's effectively unlimited, but it prevents that ":setlocal
textwidth=78" from triggering.

When undone, it should un-set the local version, reverting back to
the global option.

-tim




glts

unread,
Mar 22, 2015, 5:21:13 AM3/22/15
to vim...@googlegroups.com
On Saturday, March 21, 2015 at 5:12:17 PM UTC+1, porphyry5 wrote:
> (...)
>
> Thank you, by a happy coincidence it has occurred again, and
> :verbose set tw?
> reveals the culprit to be /usr/share/vim/vim74/ftplugin/vim.vim
> maintained by one Bram Moolenaar
> rather incontrovertibly proving my claim that this thing was set by vim itself.
>
> Thank you again, its easy to fix.

Arguably this is a mistake in the vim ftplugin.

For most programming languages line length is just user preference. Most
ftplugins don't set 'textwidth', and perhaps the vim ftplugin shouldn't
do so neither. I think it's fair to say that many people will find a
setting of 78 inappropriate.


--
David

Elimar Riesebieter

unread,
Mar 22, 2015, 9:16:51 AM3/22/15
to vim...@googlegroups.com
* glts <676c...@gmail.com> [2015-03-22 02:21 -0700]:

> On Saturday, March 21, 2015 at 5:12:17 PM UTC+1, porphyry5 wrote:
> > (...)
> >
> > Thank you, by a happy coincidence it has occurred again, and
> > :verbose set tw?
> > reveals the culprit to be /usr/share/vim/vim74/ftplugin/vim.vim
> > maintained by one Bram Moolenaar
> > rather incontrovertibly proving my claim that this thing was set by vim itself.
> >
> > Thank you again, its easy to fix.
>
> Arguably this is a mistake in the vim ftplugin.

It turns out that vim.vim sets tw=78 only if the user has set tw=0:

" Format comments to be up to 78 characters long
if &tw == 0
setlocal tw=78
endif

It might not be a mistake, though.

Elimar
--
You cannot propel yourself forward by
patting yourself on the back.

toothpik

unread,
Mar 22, 2015, 10:46:46 AM3/22/15
to vim...@googlegroups.com
On Sun, Mar 22, 2015 at 02:16:09PM +0100, Elimar Riesebieter wrote:
> * glts <676c...@gmail.com> [2015-03-22 02:21 -0700]:

> > On Saturday, March 21, 2015 at 5:12:17 PM UTC+1, porphyry5 wrote:
> > > (...)
> > >
> > > Thank you, by a happy coincidence it has occurred again, and
> > > :verbose set tw?
> > > reveals the culprit to be /usr/share/vim/vim74/ftplugin/vim.vim
> > > maintained by one Bram Moolenaar
> > > rather incontrovertibly proving my claim that this thing was set by vim itself.
> > >
> > > Thank you again, its easy to fix.
> >
> > Arguably this is a mistake in the vim ftplugin.

> It turns out that vim.vim sets tw=78 only if the user has set tw=0:

> " Format comments to be up to 78 characters long
> if &tw == 0
> setlocal tw=78
> endif

> It might not be a mistake, though.

a comment above that code implies the textwidth adjustment is there so
comments will be nicely formatted, but (and it sure looks like a bug to
me) the setting applies to the whole buffer, not just the comments

if we were voting on this I'd vote to remove it

--
_|_ _ __|_|_ ._ o|
|_(_)(_)|_| ||_)||<
|

Gevisz

unread,
Mar 22, 2015, 3:05:37 PM3/22/15
to vim...@googlegroups.com
Of course, it should be removed, unless a humiliation on users is indented by design.

porphyry5

unread,
Mar 23, 2015, 2:44:37 PM3/23/15
to vim...@googlegroups.com
Nice play on dyslexia!

Gevisz

unread,
Mar 23, 2015, 4:39:38 PM3/23/15
to vim...@googlegroups.com
I've meant "intended by design".

> Nice play on dyslexia!

Have not got your joke.

I also quite irritated by this persistent change from tw=0 to tw=78 sometimes.

Christian Brabandt

unread,
Mar 23, 2015, 4:43:09 PM3/23/15
to vim...@googlegroups.com
On Mo, 23 Mär 2015, Gevisz wrote:

> I also quite irritated by this persistent change from tw=0 to tw=78 sometimes.

Create an autocommand:

au FileType vim :set tw=0

Alternatively, use a after ftplugin like this:
http://vimhelp.appspot.com/vim_faq.txt.html#faq-26.6

Best,
Christian
--
Glück ist Scharfsinn für Gelegenheiten und die Fähigkeit sie zu
nutzen.
-- Samuel Goldwyn (eigentl. Goldfish)

Gevisz

unread,
Mar 25, 2015, 5:01:07 AM3/25/15
to vim...@googlegroups.com
On Mon, 23 Mar 2015 21:43:04 +0100 Christian Brabandt <cbl...@256bit.org> wrote:

> On Mo, 23 Mär 2015, Gevisz wrote:
>
> > I also quite irritated by this persistent change from tw=0 to tw=78 sometimes.
>
> Create an autocommand:
>
> au FileType vim :set tw=0
>
> Alternatively, use a after ftplugin like this:
> http://vimhelp.appspot.com/vim_faq.txt.html#faq-26.6
>
> Best,
> Christian

Thank you, Chistian. Your tips are always useful.

But so far, I have already found the place where tw was set to 78 in my case (and deleted it :).

Hopefully, it will be enough to get rid of this situation in the future.

If not, I will try your suggestion.

toothpik

unread,
Mar 25, 2015, 5:20:27 AM3/25/15
to vim...@googlegroups.com
the next update to the vim.vim in the runtime ftplugin folder will wipe
out any changes you make to that module, which is why we are
recommending creating an after directory to hold your override -- it is
bad practice to change anything in the runtime directory

no update from Bram will ever touch anything in your
~/.vim/after/ftplugin directory


Gevisz

unread,
Mar 25, 2015, 6:12:19 AM3/25/15
to vim...@googlegroups.com
Thank you for explanation, I will take it into account,
but in my case I was disturbed by setting tw=78 that happened
not in vim.vim but in my local .vimrc (in the part of it that
remained from the original .vimrc that has been installed
by default, sorry to accept it). Somehow and sometimes it
overided the settings I set in a ~/.vim/ftplugin/myfiletype.vim

I have found out it due to the
:verbose set tw
tip from this thread.

P.S. Just now had a look into my ~/.vimrc again.
Now the corresponding line looks like
autocmd FileType text setlocal textwidth=0
It is very similar to that was proposed by Christian.

porphyry5

unread,
Mar 25, 2015, 1:35:45 PM3/25/15
to vim...@googlegroups.com
My apologies, I assumed you were making a word-play in the same vein as the joke "dyslexics untie", rather than it being a typo.
Reply all
Reply to author
Forward
0 new messages