On Mo, 25 Jun 2018, Blay263 wrote:
> So just to give more context about a year ago the SAS vim files were
> updated. For the most part the updates were great but indenting hasn't
> worked since then.To reproduce: gvim --clean test.sas(attached). Then
> =G.indentation is removed . Expect indentation .

First of all, I don't know the language, but I found two problems with 
the distributed indent script. It worked for me in my regular setup, but 
didn't work when using vim --clean for two reasons:

     1) It seems, statements are case insensitive. However the indent
        script does not account for that and uses whatever your 
        'ignorecase' setting is. That should be fixed by using the `=~#` 
        for matching regexpes.
     2) The indent script uses the softtabstop value directly. But that
        might be zero or negative, in which case I think the 
        shiftwidth() function should be used.

With those changes, it indents your file to:

,----
| Proc sql;
|         create table legacy as
|         select * from table1 as a
|         where a.PolNo in (select distinct PolNo from table2);
|         quit;
`----

Attached is the patch for Keny to apply.

Best,
Christian 
-- 
Jeder sollte sich eine Überseh-Stunde seines Tags oder Treibens
wählen, und zwar nicht eine spazierende im Freien, sondern eine dunkle
in der Dämmerung, wo nichts ihn durch seine Sinnen unterbricht.
                -- Jean Paul

-- 
-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/indent/sas.vim b/runtime/indent/sas.vim
index d591b2796..916a25ad8 100644
--- a/runtime/indent/sas.vim
+++ b/runtime/indent/sas.vim
@@ -47,12 +47,17 @@ let s:run_processing_procs = [
       \ 'iml',
       \ ]
 
+" return the effective value of softtabstop setting
+function! s:Sts()
+  return (&sts > 0) ? &sts : shiftwidth()
+endfunction
+
 " Find the line number of previous keyword defined by the regex
 function! s:PrevMatch(lnum, regex)
   let prev_lnum = prevnonblank(a:lnum - 1)
   while prev_lnum > 0
     let prev_line = getline(prev_lnum)
-    if prev_line =~ a:regex
+    if prev_line =~? a:regex
       break
     else
       let prev_lnum = prevnonblank(prev_lnum - 1)
@@ -71,11 +76,11 @@ function! GetSASIndent()
     let prev_line = getline(prev_lnum)
     " Previous non-blank line contains the start of a macro/section/block
     " while not the end of a macro/section/block (at the same line)
-    if (prev_line =~ s:section_str && prev_line !~ s:section_run && prev_line !~ s:section_end) ||
-          \ (prev_line =~ s:block_str && prev_line !~ s:block_end) ||
-          \ (prev_line =~ s:macro_str && prev_line !~ s:macro_end)
-      let ind = indent(prev_lnum) + &sts
-    elseif prev_line =~ s:section_run && prev_line !~ s:section_end
+    if (prev_line =~? s:section_str && prev_line !~? s:section_run && prev_line !~? s:section_end) ||
+          \ (prev_line =~? s:block_str && prev_line !~? s:block_end) ||
+          \ (prev_line =~? s:macro_str && prev_line !~? s:macro_end)
+      let ind = indent(prev_lnum) + s:Sts()
+    elseif prev_line =~? s:section_run && prev_line !~? s:section_end
       let prev_section_str_lnum = s:PrevMatch(v:lnum, s:section_str)
       let prev_section_end_lnum = max([
             \ s:PrevMatch(v:lnum, s:section_end),
@@ -83,9 +88,9 @@ function! GetSASIndent()
             \ s:PrevMatch(v:lnum, s:program_end)])
       " Check if the section supports run-processing
       if prev_section_end_lnum < prev_section_str_lnum &&
-            \ getline(prev_section_str_lnum) =~ '\v%(^|;)\s*proc\s+%(' .
+            \ getline(prev_section_str_lnum) =~? '\v%(^|;)\s*proc\s+%(' .
             \ join(s:run_processing_procs, '|') . ')>'
-        let ind = indent(prev_lnum) + &sts
+        let ind = indent(prev_lnum) + s:Sts()
       else
         let ind = indent(prev_lnum)
       endif
@@ -95,26 +100,26 @@ function! GetSASIndent()
   endif
   " Re-adjustments based on the inputs of the current line
   let curr_line = getline(v:lnum)
-  if curr_line =~ s:program_end
+  if curr_line =~? s:program_end
     " End of the program
     " Same indentation as the first non-blank line
     return indent(nextnonblank(1))
-  elseif curr_line =~ s:macro_end
+  elseif curr_line =~? s:macro_end
     " Current line is the end of a macro
     " Match the indentation of the start of the macro
     return indent(s:PrevMatch(v:lnum, s:macro_str))
-  elseif curr_line =~ s:block_end && curr_line !~ s:block_str
+  elseif curr_line =~? s:block_end && curr_line !~? s:block_str
     " Re-adjust if current line is the end of a block
     " while not the beginning of a block (at the same line)
     " Returning the indent of previous block start directly
     " would not work due to nesting
-    let ind = ind - &sts
-  elseif curr_line =~ s:section_str || curr_line =~ s:section_run || curr_line =~ s:section_end
+    let ind = ind - s:Sts()
+  elseif curr_line =~? s:section_str || curr_line =~? s:section_run || curr_line =~? s:section_end
     " Re-adjust if current line is the start/end of a section
     " since the end of a section could be inexplicit
     let prev_section_str_lnum = s:PrevMatch(v:lnum, s:section_str)
     " Check if the previous section supports run-processing
-    if getline(prev_section_str_lnum) =~ '\v%(^|;)\s*proc\s+%(' .
+    if getline(prev_section_str_lnum) =~? '\v%(^|;)\s*proc\s+%(' .
           \ join(s:run_processing_procs, '|') . ')>'
       let prev_section_end_lnum = max([
             \ s:PrevMatch(v:lnum, s:section_end),
@@ -128,7 +133,7 @@ function! GetSASIndent()
             \ s:PrevMatch(v:lnum, s:program_end)])
     endif
     if prev_section_end_lnum < prev_section_str_lnum
-      let ind = ind - &sts
+      let ind = ind - s:Sts()
     endif
   endif
   return ind

Raspunde prin e-mail lui