I find that macros are an awesome way to do unusual stuff if you are interested in doing that no more than once in a blue moon. Let's say you have the following table:
%
% Not Important
% O ------------------------->
% | Stuff in side the table
% S |
% o | So you can't just write your
% m |
% e | text and transform it into
% |
% M | the shape that you want
% s |
% g | Macros help here
% |
% V
And let's say you want to replace Some Msg
with Other Message
. First off, let's extend the table for the extra character (line before last yy5p
:
%
% Not Important
% O ------------------------->
% | Stuff in side the table
% S |
% o | So you can't just write your
% m |
% e | text and transform it into
% |
% M | the shape that you want
% s |
% g | Macros help here
% |
% |
% |
% |
% |
% |
% V
The macro I'm going to come up with is going to take care of converting the text from horizontal to vertical while replacing the old text. Start by typing the text in the first location (cursor is at the end of Other Message
):
%
% Not Important
% O ------------------------->
% | Stuff in side the table
% SOther Message |
% o | So you can't just write your
% m |
% e | text and transform it into
% |
% M | the shape that you want
% s |
% g | Macros help here
% |
% |
% |
% |
% |
% |
% V
Record the following macro:
qq
: start recording macro named q
^
: go to beginning of line
3l
: move to the column where the text is going to be placed
x
: delete the old character
l
: move right, leaving one character from the message in place of the old character:
v
: go to visual mode
f|
: jump to |
2h
: move back two characters
d
: cut selection
j
: move down
P
: paste before cursor
q
: terminate recording the macro
At this point you have:
%
% Not Important
% O ------------------------->
% | Stuff in side the table
% O |
% other Message | So you can't just write your
% m |
% e | text and transform it into
% |
% M | the shape that you want
% s |
% g | Macros help here
% |
% |
% |
% |
% |
% |
% V
Repeat the macro enough number of times (i.e, the number of characters, but you don't need to know it in advance. Just underestimate, and continue once you see how close your estimate was). So let's go with 10@q
. You get:
%
% Not Important
% O ------------------------->
% | Stuff in side the table
% O |
% t | So you can't just write your
% h |
% e | text and transform it into
% r |
% | the shape that you want
% M |
% e | Macros help here
% s |
% s |
% a |
% ge |
% |
% |
% V
Ok, one more (@q
):
%
% Not Important
% O ------------------------->
% | Stuff in side the table
% O |
% t | So you can't just write your
% h |
% e | text and transform it into
% r |
% | the shape that you want
% M |
% e | Macros help here
% s |
% s |
% a |
% g |
% e |
% |
% V
Your cursor is now on the last e
. The macro doesn't work well with the last letter (you can try with @q
and then u
(undo) for unsatisfactory results). Simply adjust it yourself (X
for backspace).
:s/./% \0\r/
to add the%
and newlines ... Not a great solution, though...