I was unable to figure out how to do that. As the last line of my Makefile.am I always put:

# vim: set tabstop=4 shiftwidth=4 noexpandtab:

since, by default, these guys around me (I'm the new guy) like expandtab which, as you know, is problematic for makefiles.

Best,

Russ


John Orr wrote:
Thanks Eric.  I don't know that I explained myself that well - if the code is 
this:
foo.o : foo.c
<tab>  the command to build foo.o starts here but \
<spaces>  the command is long

then vim's syntax highlighting will flag an error if the backslash is lost, 
because this is invalid:
foo.o : foo.c
<tab> the command to build foo.o starts here but <spaces> the command is long

But if the indenting is as vim encourages, like this:
foo.o : foo.c
<tab>  the command to build foo.o starts here but \
<tab>  the command is long

then vim syntax highlighting won't spot the problem of a lost backslash in this:
foo.o : foo.c
<tab>  the command to build foo.o starts here but
<tab>  the command is long

Hence my preference for the former.

Another alternative might be to enable expandtab (to get the spaces) and enter 
the tab characters explicitly - is there any easy way of inserting a tab 
character when expandtab is enabled?


On Friday 16 June 2006 16:45, Eric Arnold wrote:
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