On Tuesday, July 26, 2016 at 12:47:43 AM UTC-5, Rob Foehl wrote:
> On Mon, 25 Jul 2016, Ben Fritz wrote:
> 
> > Makefiles are the only place I can think of where I use 'preserveindent' 
> > and 'copyindent'.
> >
> > This way recipes always have the syntactically required leading TAB indent, 
> > but any spaces used for indent or alignment afterward are maintained when I 
> > add/remove indent or create a new line in the recipe.
> 
> Are you sure?  Try adding indentation across lines with tabs-before-spaces 
> indentation and alignment, with 'listchars' set to some value that'll make 
> the tabs obvious.  I don't think it does what you expect, which is kinda 
> my point here... ;)
> 

Yes, I'm sure. I tested with 'expandtab' set on a makefile with a single tab 
and 4 spaces on a line, with 'shiftwidth' and 'tabstop' both set to 4.

With 'preserveindent' on, the tab character remains where it is when I use >>, 
<<, or visually select and use > or <. Only spaces get added, and only *after* 
the leading tab.

With 'preserveindent' off, the leading tab gets replaced by spaces, breaking 
the makefile.

I almost always have listchars set to see tabs differently from spaces, I only 
turn it off occasionally when I need to for some specific purpose or another.

> Here's an example from Vim's own Makefile...  If I visually select the 
> recipe for this rule and shift it once to the right:
> 
> prepare:
> >-------if test -f runtime/doc/uganda.nsis.txt; then \
> >------->-------rm runtime/doc/uganda.nsis.txt; fi
> >-------for name in $(IN_README_DIR); do \
> >-------  cp READMEdir/"$$name" .; \
> >-------  done
> 
> I get this result:
> 
> prepare:
> >------->-------if test -f runtime/doc/uganda.nsis.txt; then \
> >------->------->-------rm runtime/doc/uganda.nsis.txt; fi
> >------->-------for name in $(IN_README_DIR); do \
> >-------  >-----  cp READMEdir/"$$name" .; \
> >-------  >-----  done
> 
> That odd run of an extra copy of the spaces plus another tab is the 
> problem.  My expectation here would've been for an extra tab to be 
> inserted at the beginning of each line, and nothing more.
> 
> (For reference, this was with ':set lcs=tab:>- ci pi noet ts=8 sw=8 sts=0' 
> in Vim 7.4.1868, as currently packaged in Fedora.  The 'ci' setting 
> doesn't actually matter here, nor does the exact shift method used.)
> 

I'm not sure why spaces get inserted at all in this scenario. That seems 
strange. I see why that would be annoying.

> > Currently >> and << on these lines will keep the leading TAB. If I 
> > understand your proposal correctly, this property could be lost, breaking 
> > the makefile.
> 
> Quite the contrary, modifying only the leading indentation (tabs, in this 
> case) when shifting is exactly the behavior I want.  It's not what we get 
> from 'preserveindent' today, and it's what the 'leftindent' patch intended 
> to accomplish.  It also seems like a reasonable expectation for what 
> 'preserveindent' *should* do, hence the question...
> 

Modifying the leading indentation is only what you want, if you assume the 
leading indentation matches the 'expandtab' setting. I see 'preserveindent' 
(especially when combined with 'copyindent') as explicitly telling Vim "I know 
my indent is weird here, please don't mess with it". I think it deserves a 
separate option if you want to change what part of the indentation Vim is 
allowed to mess with, since leading indent is syntactically important sometimes.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui