Here's a little patch that makes the indentation after if, else, and for
statements far less quirky.
Instead of:
if a <> b then
begin
FlagOK
end;
for i := 0 to 9 do
begin
UpdateRecord(i)
end;
*next-statement*
with my patch applied, it's:
if a <> b then
begin
FlagOK;
end;
for i := 0 to 9 do
begin
UpdateRecord(i)
end;
*next-statement*
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
*** runtime/indent/pascal.vim.old 2008-12-16 17:28:49.000000000 -0500
--- runtime/indent/pascal.vim 2008-12-17 15:55:34.000000000 -0500
***************
*** 2,8 ****
" Language: Pascal
" Maintainer: Neil Carter <[email protected]>
" Created: 2004 Jul 13
! " Last Change: 2005 Jul 05
if exists("b:did_indent")
--- 2,8 ----
" Language: Pascal
" Maintainer: Neil Carter <[email protected]>
" Created: 2004 Jul 13
! " Last Change: 2008 Dec 17
if exists("b:did_indent")
***************
*** 102,108 ****
endif
" If the previous line was indenting...
! if prev_codeline =~ '^\s*\<\(for\|if\|case\|else\|end\ else\)\>'
" then indent.
let indnt = indnt + &shiftwidth
" BUT... if this is the start of a multistatement block then we
--- 102,108 ----
endif
" If the previous line was indenting...
! if prev_codeline =~ '^\s*\<\(case\|end\ else\)\>'
" then indent.
let indnt = indnt + &shiftwidth
" BUT... if this is the start of a multistatement block then we
***************
*** 114,123 ****
" We also need to keep the indentation level constant if the
" whole if-then statement was on one line.
if prev_codeline =~ '\<then\>.\+'
! let indnt = indnt - &shiftwidth
endif
endif
" PREVIOUS-LINE BEGIN
" If the previous line was an indenting keyword then indent once...
if prev_codeline =~ '^\s*\<\(const\|var\|begin\|repeat\|private\)\>'
--- 114,129 ----
" We also need to keep the indentation level constant if the
" whole if-then statement was on one line.
if prev_codeline =~ '\<then\>.\+'
! let indnt = indnt - &shiftwidth
endif
endif
+ " Indent for those who like to write the begin on the same line
+ " as the if
+ if prev_codeline =~ '\<then\ begin\>$'
+ return indnt + &shiftwidth
+ endif
+
" PREVIOUS-LINE BEGIN
" If the previous line was an indenting keyword then indent once...
if prev_codeline =~ '^\s*\<\(const\|var\|begin\|repeat\|private\)\>'
***************
*** 148,154 ****
" At the end of a block, we have to unindent both the current line
" (the "end" for instance) and the newly-created line.
! if this_codeline =~ '^\s*\<\(end\|until\|else\)\>'
return indnt - &shiftwidth
endif
--- 154,160 ----
" At the end of a block, we have to unindent both the current line
" (the "end" for instance) and the newly-created line.
! if this_codeline =~ '^\s*\<\(end\|until\|else\)\>' && prev_codeline !~ '\<end\>$'
return indnt - &shiftwidth
endif