(Assign tip id + convert to TipNew template) |
(Change <tt> to <code>, perhaps also minor tweak.) |
||
Line 3: | Line 3: | ||
|previous=1619 |
|previous=1619 |
||
|next=1621 |
|next=1621 |
||
− | |created= |
+ | |created=2009 |
|complexity=basic |
|complexity=basic |
||
|author=Sightless |
|author=Sightless |
||
Line 11: | Line 11: | ||
|category2= |
|category2= |
||
}} |
}} |
||
− | This snippet, which should be put in < |
+ | This snippet, which should be put in <code>~/.vim/indent/c.vim</code> to work, gives indentation like this: |
<pre> |
<pre> |
||
for (;;) |
for (;;) |
Latest revision as of 06:39, 13 July 2012
Tip 1620 Printable Monobook Previous Next
created 2009 · complexity basic · author Sightless · version 7.0
This snippet, which should be put in ~/.vim/indent/c.vim
to work, gives indentation like this:
for (;;) { do_something(); }
rather than having the contents of the loop at the same indent level as the 'for' keyword.
func! MyCindent(l) let extra = match(getline(a:l),'^\s*{.*}$')==-1?0:&sw return cindent(a:l)+extra endfunc setlocal indentexpr=MyCindent(v:lnum) setlocal cinkeys+=} let &l:indentkeys=&l:cinkeys