[PATCH] New option: leftindent
Michael Gold <mgold <at> connect.carleton.ca>
2005-10-02 06:14:34 GMT
The attached patch for Vim 6.3 adds a new option called 'leftindent'
(short form 'li'). It is similar to preserveindent, but adds and removes
indentation at the far left end of the line rather than immediately
before the first non-whitespace character. You can enter the following
code in Vim to see my problem with preserveindent (use ":set noet pi
ts=4 sw=4 sts=0"):
function(a,
b); // 9 spaces before b, aligning it with a
If you use >> to indent all 3 lines, you'll get this (">--" is a tab):
>---function(a,
>-- b); // 9 spaces, a tab, and 1 space before b
If you change the tab width (ts=3 for example) the letters no longer
line up. I'd expect my code to display properly regardless of the tab
width. With leftindent it does; this is the result:
>---function(a,
>--- b); // 1 tab and 9 spaces before b
[ if you take this code and use << with the above :set line, you'll see
a similar problem with unindenting - again, a and b won't line up when
you change the tab width ]
I always use shiftwidth == tabstop, but I've tried to make the code work
when this isn't true (for example, with Vim's code which uses ts=8 sts=4
sw=4). A possible issue is that >> would always insert some spaces, and
these would build up with repeated indentation (and if sw < ts you'd
(Continue reading)