title: Vim get length of matched line
body: <p>I am trying to use vim substitute commands to transform type specific C-code into macro Code. This example snippet </p>
  
  <pre><code>#define LIST_GEN_FUNCS(TYPE)
  struct list_##TYPE* list_generate() {  
  struct list_##TYPE* ret = malloc(sizeof(struct list));
  ret-&gt;len = 0; ret-&gt;first = 0;
  return ret;
  }
  </code></pre>
  
  <p>needs to look like that:</p>
  
  <pre><code>#define LIST_GEN_FUNCS(TYPE)                               
  struct list_##TYPE* list_generate() {                     \
  struct list_##TYPE* ret = malloc(sizeof(struct list));    \
  ret-&gt;len = 0; ret-&gt;first = 0;                             \
  return ret;                                               \
  }                                                         \
  </code></pre>
  
  <p>To do this, i need a way to fill up all columns with whitespaces until a fixed line length, then add '\' after each line ending.</p>
  
  <pre><code>%s/$/\= submatch(0) . " " . repeat(" ", 78 - LENGTH_OF_LINE)
  </code></pre>
  
  <p>Now, here is my problem. I was not able to find out how to get the length of a matched line. Could anyone tell me, what to insert as LENGTH_OF_LINE?</p>