diff --git a/.gitattributes b/.gitattributes
index 08fa521ed5..312f2cfff5 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,3 @@
 *.factor text eol=lf
 *.html text eol=lf
+misc/vim/ftplugin/factor.vim linguist-generated
diff --git a/misc/vim/ftdetect/factor.vim b/misc/vim/ftdetect/factor.vim
index eb9c0deda6..733cc5ba27 100644
--- a/misc/vim/ftdetect/factor.vim
+++ b/misc/vim/ftdetect/factor.vim
@@ -1 +1,3 @@
-autocmd BufRead,BufNewFile *.factor,{,.}factor*-rc set filetype=factor
+" autocmd BufRead,BufNewFile *.factor setf factor " upstreamed
+autocmd BufRead,BufNewFile {,.}factor*-rc setf factor
+autocmd BufRead,BufNewFile *-docs.factor set ft=factor.factor-docs
diff --git a/misc/vim/ftplugin/factor-docs.vim b/misc/vim/ftplugin/factor-docs.vim
new file mode 100644
index 0000000000..cf2611d998
--- /dev/null
+++ b/misc/vim/ftplugin/factor-docs.vim
@@ -0,0 +1,10 @@
+" Vim filetype plugin file
+" Language: Factor (documentation)
+" Maintainer: Tim Allen <screwtape@froup.com>
+" Last Change: 2020 May 29
+
+" Documentation lines can be any length of characters.
+setlocal textwidth=0
+augroup factorTextWidth
+    au!
+augroup END
diff --git a/misc/vim/ftplugin/factor.vim b/misc/vim/ftplugin/factor.vim
index bb34b3a60d..002330b4b0 100644
--- a/misc/vim/ftplugin/factor.vim
+++ b/misc/vim/ftplugin/factor.vim
@@ -15,14 +15,13 @@ let b:did_ftplugin = 1
 " Tabs are not allowed in Factor source files; use four spaces instead.
 setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4
 
-" Try to limit lines to 64 characters, except for documentation, which can be
-" any length.
-if expand("%:t") !~ "-docs\.factor$"
-    setlocal textwidth=64
-
-    " Mark anything in column 64 or beyond as a syntax error.
-    match Error /\%>63v.\+/
-endif
+" Try to limit lines to 64 characters.
+setlocal textwidth=64
+augroup factorTextWidth
+    au!
+    au BufEnter <buffer> 2match Error /\%>64v.\+/
+    au BufLeave <buffer> 2match none
+augroup END
 
 " Teach Vim what comments look like.
 setlocal comments+=b:!,b:#!