I want to use the nuweb.vim extension for syntax highlighting nuweb files.

Long story short, nuweb files are basically a super-set of latex files. There is added syntax and markers to embed code-snippets in Latex so that one can do literate programming in the style of Knuth.

However, I have not been able to get the nuweb.vim file to get to work for nuweb files. (These typically have extensions .nw)

Here a sample nuweb file, titled fun.nw

$\alpha + \beta=\gamma$

@o output.cpp
@{# /* C++*/
int main(void){
  std::cout << "Hello World" << std::endl;
  return 0;


My .vimrc file looks like this

colorscheme torte
set guifont=Inconsolata\ 14
set laststatus=2

filetype on
filetype plugin on

set runtimepath^=/home/smilingbuddha/.vim/bundle/nuweb.vim

On opening the nuweb files, I don't get the necessary syntax highlightin. Doing :set syntax? I get output syntax=conf in the mode-line at the bottom.

Where am I going wrong? I am not used to Vim so I am pretty much a newbie.

  • put the syntax\nuweb.vim inside ~/.vim/syntax. If Vim already detects nuweb files, it should just work, else you would need an additional rule to detect a new filetype (see :h new-filetype) Commented Nov 25, 2018 at 8:16
  • 1
    Check :set ft?
    – D. Ben Knoble
    Commented Nov 25, 2018 at 14:10

2 Answers 2


The vimscripts entry for nuweb.vim (which is referred to by the README.md in the GitHub repository) gets into more details about how to install it:

install details
As WEB/CWEB uses *.w, i recoment use *.nw for NUWEB, so some like
au BufNewFile,BufRead *.nw setf nuweb
in filetype.vim will do the trick.

In modern Vim, this is typically accomplished by an ftdetect plug-in, so you should probably include a ~/.vim/ftdetect/nuweb.vim with exactly those contents listed above. Create that file with this single line in it:

au BufNewFile,BufRead *.nw setf nuweb

Perhaps it would make sense to suggest including this ftdetect/nuweb.vim with the GitHub repository for it. But given the GitHub repository hasn't been touched in 10 years and the vimscripts page for the plug-in is actually even older, from 2003, I don't know whether you'll have luck in getting any of the maintainers to incorporate that suggestion...


Simply put syntax on on your vimrc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.