I often encounter situations in editing text or code where I want to insert a rectangle of spaces to align things, but I don't know exactly the number of spaces to insert.
For example, consider the following (very much contrived) snippet:
void *var = (void *)typedVar;
void *otherVar = voidStarOtherVar;
int intVar = x*y;
int intVar2 = y*z;
In default C-mode, M-x align results in this, which is better:
void *var = (void *)typedVar;
void *otherVar = voidStarOtherVar;
int intVar = x*y;
int intVar2 = y*z;
However, suppose my desired alignment (for some reason) is this:
void *var = (void *)typedVar;
void *otherVar = voidStarOtherVar;
int intVar = x*y;
int intVar2 = y*z;
The only way I know to do that is with M-x string-rectangle on the bottom three lines, and type in the exact number of spaces.
However, I don't want to count the number of characters in (void *) before typing in the spaces, thus it would be nice to have an "interactive" rectangle string insert. For example, I type a space in this interactive mode, and I see it reflected immediately in the text. I enter another space, and it is inserted. In this way I can interactively align the text to my desired position.
Is there a built-in way to accomplish this? Or, failing that, can I create this functionality somehow?