Question

I have:

$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Dec  1 2011 03:25:24)

using Debian testing.

I was playing around with an old manpage I wrote and noticed that vim (I used gedit to write it initially but have switched to vim) is not recognizing it as a nroff/groff filetype upon loading or with a:

:filetype detect

It does syntax highlighting fine, of course, with:

:set filetype=groff

Anyone else have this behaviour and if so find a fix?

BTW, it recognizes html, bash, and python scripts correctly and sets the correct syntax highlighting. Just seems to balk at groff files that are saved without the [FILENAME].1-type suffix.

Cheerio, Narnie

Was it helpful?

Solution

Vim can detect the filetype based on both the name of the file and the context. It appears that in this case vim only looks at the file name. You can write your own filetype detection script to figure out files of this type based on the context. The vim's help has some basic instructions on how to do this. Basically you can just write a vim script that detects the file type and put it in $VIMRUNTIME/scripts.vim.

OTHER TIPS

Add in your ~/.vimrc file:

au BufNewFile,BufRead *.groff set filetype=groff

Or whatever extension you're using to define your groff files.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top