If the :Make
command you are using is this one, then your issue may come from the fact that it was not given the -bar
attribute when it was defined. See :h :command-bar
:
-bar The command can be followed by a "|" and another command.
A "|" inside the command argument is not allowed then.
Also checks for a " to start a comment.
There are other solutions, but the simplest one may be to hide | endif
from :Make
by wrapping it inside a string, and executing the latter with :execute
:
autocmd BufWritePost *.c,*.cpp,*.h
\ let dir=expand('<amatch>:p:h')
\ | if filereadable(dir.'/Makefile') || filereadable(dir.'/makefile')
\ | exe 'Make > /dev/null'
\ | endif
For the complete list of commands which, like :Make
, see the |
as part of their argument, see :h :bar
:
These commands see the '|' as their argument, and can therefore not be
followed by another Vim command:
:argdo
:autocmd
:bufdo
:cdo
:cfdo
:command
:cscope
:debug
:folddoopen
:folddoclosed
:function
:global
:help
:helpfind
:lcscope
:ldo
:lfdo
:make
:normal
:perl
:perldo
:promptfind
:promptrepl
:pyfile
:python
:registers
:read !
:scscope
:sign
:tcl
:tcldo
:tclfile
:vglobal
:windo
:write !
:[range]!
a user defined command without the "-bar" argument |:command|