I want to set my markdown files to have textwidth=100
but cannot get it working. The strange thing is that it works sometimes and sometimes not. My autocmd is:
augroup auFileTypes
autocmd! auFileTypes
audocmd BufNewFile,BufRead *.md set filetype=markdown | setlocal textwidth=100
augroup end
Some files (such as create_template.md
or index.md
) just work; some files (such as completed_jobs.md
or issues.md
) don't work.
I thought at first it might be a "sequencing" problem such as every other one works, but that turned out not to be the case.
I'm on version 8.1-650, via Homebrew.
UPDATE:
When I load the file completed_jobs.md
, :setlocal says this:
--- Local option values ---
autoindent cryptmethod= errorformat= grepprg= linebreak number scroll=33 sidescrolloff=-1 syntax=markdown
--autoread cursorline expandtab include= lispwords= path= scrolloff=-1 softtabstop=2 tabstop=2
backupcopy= define= filetype=markdown keywordprg= makeprg= relativenumber shiftwidth=2 noswapfile tagcase=
cinkeys=0{,0},0),:,0#,!^F,o,O,e
comments=fb:*,fb:-,fb:+,n:>
commentstring=<!--%s-->
fileencoding=utf-8
formatlistpat=^\s*\d\+\.\s\+\|^[-*+]\s\+\|^\[^\ze[^\]]\+\]:
indentkeys=0{,0},:,0#,!^F,o,O,e
iskeyword=@,48-57,_,192-255,$
tags=./tags,tags,~/workspace/automation-ui-core-etap/tags
undolevels=-123456
and `onboarding.md :setlocal says this:
--- Local option values ---
autoindent cryptmethod= noendofline filetype=markdown keywordprg= makeprg= relativenumber shiftwidth=2 noswapfile tagcase=
--autoread cursorline errorformat= grepprg= linebreak number scroll=33 sidescrolloff=-1 syntax=markdown textwidth=100
backupcopy= define= expandtab include= lispwords= path= scrolloff=-1 softtabstop=2 tabstop=2
cinkeys=0{,0},0),:,0#,!^F,o,O,e
comments=fb:*,fb:-,fb:+,n:>
commentstring=<!--%s-->
fileencoding=utf-8
formatoptions=tcqln
formatlistpat=^\s*\d\+\.\s\+\|^[-*+]\s\+\|^\[^\ze[^\]]\+\]:
indentkeys=0{,0},:,0#,!^F,o,O,e
iskeyword=@,48-57,_,192-255,58,-,$
tags=./tags,tags,~/workspace/automation-ui-core-etap/tags
undolevels=-123456
Only difference I can see (besides the missing textwidth=100
) is the noendofline
setting. However, even that is not consistent across the various successes and failures.
auFileTypes
afterautocmd!
(I'm not sure it has an impact but I had not seen this syntax before). Second, why do you useset filetype
in your autocommand? I think the built-in plugin should set the filetype correctly by itself. Finally rather than using an autocommand you could simply create~/.vim/after/ftplugin/markdown.vim
and putsetlocal textwidth=100
in it, this way you let the built in mechanisms do the work without having to mess with autocommands.:filetype
command in your .vimrc?