Saturday, March 22, 2014

Re: customize indentation

On 21.03.14 10:58, Arup Rakshit wrote:
> I wanted to my vim to configure in a way, so that I can see the
> indentation correctly happening or not. I mean if it is really 2
> spaces or more.

> Suppose, when I will be writing my code, Like below :
>
> class Foo
> . .def foo
> . . . .x = 10
> . . . . y = 12
> . .end
> end

If tabs are used, not just an amorphous pile of spaces, then indentation
information exists in the file. Then, as partially described in
":h listchars", we can:

:set tabstop=2 sw=2 noexpandtab
:set listchars+=tab:>-
:set list

so that:

class Foo
def foo
x = 10
y = 12
end
end

gains a blue ">-" for each tab present. Visually scanning the columns of
">" is much quicker than counting dots. Changing the listchars to tab:!-
makes that even easier, I find. (Attempting tab:|- generates an error.)

If you have autoindent enabled, you will also see those ">-" appear.

To turn off the indication:

:set nolist

It may be convenient to map these on and off operations to e.g. F1,F2.

Is that close enough?

Erik

--
It is not possible to have a democracy if we have to protect our users from the
government. The government has done itself a tremendous disservice and we need
to have a debate about it, - Larry Page, at TED, where Edward Snowden appeared.
<http://www.bbc.com/news/technology-26658892>

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment