title: find a line based on string pattern and move it X places
body: <p>I want to move the 1st instance of <code>AND F.col_x IS NOT NULL</code> pattern  ( for each of the blocks <code>23 24 25</code> etc ) that follows the <code>WHERE F.col_x = D.col_x</code> pattern either of these ways<br>
  --Look for <em>brackets Just before <code>group by</code></em> and add it in there <br>
  --alternately <em>move that line 1 line below from where it was taken</em>.<br>
  Either way the results would be the same </p>
  
  <p><strong>INPUT</strong> </p>
  
  <pre><code>*22 
       Select   ((MYLILFUNC(F.col_x,-99999)))   AS WIDTH,
                COUNT(*) AS  SIZE 
      FROM    MYDB.BGSQLTB F      where NOT EXISTS ( sel '1' from  MYDB.col_x D 
          WHERE F.col_x = D.col_x 
          AND F.col_x IS NOT NULL
          AND D.col_x IS NOT NULL  )  
      GROUP BY   F.col_x;
      *23 
       Select   ((MYLILFUNC(F.COL_y,-99999)))   AS WIDTH,
                COUNT(*) AS  SIZE 
      FROM    MYDB.BGSQLTB F      where NOT EXISTS ( sel '1' from  MYDB.DIM_DRG_CODE D 
          WHERE F.COL_y = D.COL_y 
      AND F.COL_y IS NOT NULL 
          AND D.COL_y IS NOT NULL  ) 
      GROUP BY   F.COL_y;
      *24 
       Select   ((MYLILFUNC(F.COL_Z,-99999)))   AS WIDTH,
                COUNT(*) AS  SIZE 
      FROM    MYDB.BGSQLTB F      where NOT EXISTS ( sel '1' from  MYDB.COL_Z D 
          WHERE F.COL_Z = D.COL_Z 
      AND F.COL_Z IS NOT NULL 
          AND D.COL_Z IS NOT NULL  ) 
      GROUP BY   F.COL_Z;
      *25 
       Select   ((MYLILFUNC(F.COL_XXX,-99999)))   AS WIDTH,
                COUNT(*) AS  SIZE 
      FROM    MYDB.BGSQLTB F      where NOT EXISTS ( sel '1' from  MYDB.COL_XX D 
          WHERE F.COL_XXX = D.COL_XXX 
      AND F.COL_XXX IS NOT NULL 
          AND D.COL_XXX IS NOT NULL  ) 
      GROUP BY   F.COL_XXX;
  </code></pre>
  
  <p><strong>OUTPUT</strong></p>
  
  <pre><code>*22 
   Select   ((MYLILFUNC(F.col_x,-99999)))   AS WIDTH,
            COUNT(*) AS  SIZE 
  FROM    MYDB.BGSQLTB F      where NOT EXISTS ( sel '1' from  MYDB.col_x D 
      WHERE F.col_x = D.col_x 
  
      AND D.col_x IS NOT NULL  ) AND F.col_x IS NOT NULL 
  GROUP BY   F.col_x;
  *23 
   Select   ((MYLILFUNC(F.COL_y,-99999)))   AS WIDTH,
            COUNT(*) AS  SIZE 
  FROM    MYDB.BGSQLTB F      where NOT EXISTS ( sel '1' from  MYDB.DIM_DRG_CODE D 
      WHERE F.COL_y = D.COL_y 
  
      AND D.COL_y IS NOT NULL  ) AND F.COL_y IS NOT NULL 
  GROUP BY   F.COL_y;
  *24 
   Select   ((MYLILFUNC(F.COL_Z,-99999)))   AS WIDTH,
            COUNT(*) AS  SIZE 
  FROM    MYDB.BGSQLTB F      where NOT EXISTS ( sel '1' from  MYDB.COL_Z D 
      WHERE F.COL_Z = D.COL_Z 
  
      AND D.COL_Z IS NOT NULL  ) AND F.COL_Z IS NOT NULL 
  GROUP BY   F.COL_Z;
  *25 
   Select   ((MYLILFUNC(F.COL_XXX,-99999)))   AS WIDTH,
            COUNT(*) AS  SIZE 
  FROM    MYDB.BGSQLTB F      where NOT EXISTS ( sel '1' from  MYDB.COL_XX D 
      WHERE F.COL_XXX = D.COL_XXX 
  
      AND D.COL_XXX IS NOT NULL  ) AND F.COL_XXX IS NOT NULL
  GROUP BY   F.COL_XXX;
  </code></pre>
  
  <p>My search pattern using Ed is a bit too wide and takes more lines and I am not sure how I can get the moving logic done because it is relative to each selected line. </p>