[prev in list] [next in list] [prev in thread] [next in thread]
List: vim-dev
Subject: Re: vim60h - new 'indent' feature
From: Bram Moolenaar <Bram () moolenaar ! net>
Date: 2000-09-30 13:45:58
[Download RAW message or body]
Aric Blumer wrote:
> The "end if" does not outdent like I expect. I see that the function
> indent(v:lnum - 1) returns the indent of the line right above the
> cursor. I take this behavior to mean that the line above "end if" has
> in indent of zero and that a return of a negative number from
> GetVimIndent does nothing to the indent.
>
> Is there a way to get the indent of the previous non-empty line?
Yes, see this code in the vim.vim indent file:
function GetVimIndent()
" Find a non-empty line above the current line.
let lnum = v:lnum - 1
while lnum > 0
if getline(lnum) !~ '^\s*$'
break
endif
let lnum = lnum - 1
endwhile
" Hit the start of the file, use zero indent.
if lnum == 0
return 0
endif
Perhaps, if this is a very common thing to do for indenting, I could make a
special function for it. Should make the indenting a bit faster.
--
hundred-and-one symptoms of being an internet addict:
62. If your doorbell rings, you think hat new mail has arrived. And then
you're disappointed that it's only someone at the door.
/// Bram Moolenaar Bram@moolenaar.net http://www.moolenaar.net \\\
\\\ Vim: http://www.vim.org ICCF Holland: http://iccf-holland.org ///
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic