Hello, list I wrote a patch to correct some problems with continuation lines inside if clauses.
In the current version of the code, the next snippet was indented as follows: do i=1,end if (condition1 .AND. & condition2) then do something end if end do In the proposed patch, I propose a 1 space indent for the continuation line (it's hardwired in the patch) to correct the bug, so the snippet now is: do i=1,end if (condition1 .AND. & condition2) then do something end if end do I have also considered continuation lines in else if constructions, while still working in logical and arithmetic ifs. Examples: if (condition) do something do something if (condition1 .AND. & condition2) do something if (condition) & do something do something I have also corrected a minor bug: block was considered when starting the construction but not at the end, not decreasing the indent. It is the first time I modify a vim indent file and I am sure that my patch can be improved. I think it is a very useful patch since it was very annoying not to have the correct indentation in these cases. Kindest regards, Albert Oliver -- -- You received this message from the "vim_dev" 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_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/indent/fortran.vim b/runtime/indent/fortran.vim --- a/runtime/indent/fortran.vim +++ b/runtime/indent/fortran.vim @@ -96,8 +96,17 @@ \ ||prevstat=~? '^\s*\(\d\+\s\)\=\s*\(\a\w*\s*:\)\=\s*if\>' let ind = ind + &sw " Remove unwanted indent after logical and arithmetic ifs - if prevstat =~? '\<if\>' && prevstat !~? '\<then\>' - let ind = ind - &sw + if prevstat =~? '\<if\>' + if prevstat =~ '&\s*$' + let ind = ind + 1 + elseif prevstat !~? '\<then\>' + let ind = ind - &sw + endif + endif + if prevstat =~? '\<else\s*if\>' + if prevstat =~ '&\s*$' + let ind = ind + 1 + endif endif " Remove unwanted indent after type( statements if prevstat =~? '^\s*type\s*(' @@ -129,7 +138,7 @@ if getline(v:lnum) =~? '^\s*\(\d\+\s\)\=\s*' \. '\(else\|else\s*if\|else\s*where\|case\|' \. 'end\s*\(if\|where\|select\|interface\|' - \. 'type\|forall\|associate\|enum\)\)\>' + \. 'type\|forall\|associate\|enum\|block\)\)\>' let ind = ind - &sw " Fix indent for case statement immediately after select if prevstat =~? '\<select\s\+\(case\|type\)\>' @@ -138,12 +147,22 @@ endif "First continuation line - if prevstat =~ '&\s*$' && prev2stat !~ '&\s*$' - let ind = ind + &sw + if prevstat =~ '&\s*$' + if prevstat =~? '\<if\>' || prevstat =~? '<else\s*if\>' + elseif prev2stat !~ '&\s*$' + let ind = ind + &sw + endif endif "Line after last continuation line if prevstat !~ '&\s*$' && prev2stat =~ '&\s*$' - let ind = ind - &sw + if prevstat =~? '\<then\>' + let ind = ind - 1 + elseif prev2stat =~? '\<if\>' + let ind = ind - 1 + let ind = ind - &sw + else + let ind = ind - &sw + endif endif return ind