Search code examples
vimmakefile

How do I get rid of the red highlighting when writing a makefile in Vim


I am writing a makefile and it keeps highlighting every word after the tab. This is an example:

enter image description here

This my .vimrc file:

filetype indent off  
set tabstop=4
set expandtab
syntax on  
colorscheme slate
set ignorecase
set number 
set nosmartindent
set noswapfile
set list
set listchars=tab:>-,trail:`,extends:>,precedes:<
set lcs+=space:·

How can I only get rid of the red highlighting? I know :syntax off will get rid of it, but it gets rid of all sorts of color changes which are useful.


Solution

  • Where you say there is a tab, there is no tab, but four spaces (as indicated by the four dots which you have configured by setting lcs).

    That's an error and it's why it is highlighted in red.

    To fix it, insert an actual tab character instead or add the following at the top of the Makefile, being careful to preserve the space at the end of the line after the closing parenthesis ) :

    # The space at the end is intentional to permit spaces instead of tabs.
    .RECIPEPREFIX := $(.RECIPEPREFIX)