On Dec 22, 4:14 pm, "Oliver Zheng" <[email protected]>
wrote:
> On Mon, Dec 22, 2008 at 1:57 PM, Erik Hahn <[email protected]> wrote:
>
> > Check out this [1] script.
>
> >  1.http://www.vim.org/scripts/script.php?script_id=231
>
> I did. However, it looks like this only "automatically converts" tabs
> to spaces during the middle of a line. For the example I gave:
>
> int main() {
> <tab>if (1)
> <tab><tab>int a = test(
> <tab><tab>.............param1, // [1]
> <tab><tab>.............param2,
> <tab><tab>............);
>
> }
>
> the script does not treat the param line [1] any differently than any
> other line. It's not really context aware of the programming language.
>
> Even if I *manually* space my way to param1 after the initial 2 tabs,
> Vim will convert my spaces to tabs when I >> or <<. Is there no way to
> let Vim recognize that spaces are a part of the contents and not
> indent? Of course, it would be much better if Vim could automatically
> insert spaces to the appropriate column when I break a statement into
> multiple lines.

Make sure 'ts' is set the same as 'sw'. I agree that using tabs always
for leading indent and spaces for subsequent alignment makes far more
sense than mixing tabs and spaces at the beginning of a line.
Fortunately, mixing of tabs and spaces happens only if your tabstop
setting is not the same as your shiftwidth: e.g., ts=8, sw=4. I
typically set both 'ts' and 'sw' to 4 since I prefer indents to appear
as 4 spaces. To those who say "but a tab is supposed to be 8 spaces",
I say "a tab isn't any amount of spaces - it is simply an indent
level". If you use tabs only for leading indent, an indent level can
be whatever you want it to be when you're viewing the file. Almost as
importantly, it can be whatever someone else wants it to be when he's
viewing the same file...

>
> Cheers,
> Oliver
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to