If you want to flag errors, why not use highlighting?  Actually, the
makefile syntax I'm seeing already highlights correct backslashes.
So, in general, you know there is an error if the code/text isn't
colored right.

I don't see a way to tell Vim to indent with tabs sometimes and not others.


On 6/15/06, John Orr <[EMAIL PROTECTED]> wrote:
Hi,

I'm currently implementing a make system with GNU Make and have been trying for 
a while to work out how to get the indentation working as I would like it to.

I believe it is reasonably standard when editing makefiles to
set noexpandtab
such that tabs are inserted when you start the commands under a rule, and 
that's great.

My problem is when you have long command lines and wish to use line 
continuation, with the following formatting:
foo.o : foo.c
<tab>  the command to build foo.o starts here but \
<spaces>  because the command is long it uses \
<spaces>  line continuation for readability \
<spaces>  and it finally ends here

Note - the command starts with a tab as it must, but the continuation lines are 
instead indented with spaces.  Why?  Because if you forget a backslash 
requesting line continuation - or if you accidentally get a space after one 
(which also breaks line continuation), then by using spaces for indentation, 
both make, and vim, will draw your attention to it.

My problem - how does one get vim to do this kind of indentation?

Admittedly I'm only using vim 6.3, but the return value of the indentexpr is a 
number, representing a number of spaces.  Your 'expandtab' setting, in 
combination with shiftwidths etc, seems to dictate whether that number of 
spaces is inserted as spaces or tabs (or tabs plus spaces).

Any suggestions on how to achieve my goal?  (Or, alternatively, any reasons why 
my goal is illogical and shouldn't be the standard way that vim works with 
Makefiles?)

The simplest I could imagine would be if the indentexpr function could return 
either a number of spaces as today, or a string consisting of the actual 
indentation characters required - but I'd rather not go hacking vim.

Thanks very much,
John

Reply via email to