Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Suppose I have this text:

RUN_
RUN_
RUN_
RUN_
RUN_

and want this one:

RUN_A
RUN_B
RUN_C
RUN_D
RUN_E

I would like to be able to write ABCDE and somehow `transpose' it and kill-yank it as a rectangle.

Can this be done without too much lisp hacking?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted
(defun insert-column (chars)
  (interactive "sChars to enter: ")
  (insert-rectangle (mapcar 'string (string-to-list chars))))
share|improve this answer
    
This is good, tanks. It would be even better if one could do it for several lines together (like rectangles). –  Alfred M. May 11 '12 at 9:57
    
You mean more than just one character per line? That's just a matter of splitting the input string differently. (But then you might as well just got with the plain rectangle operations...) –  Eli Barzilay May 11 '12 at 13:32
    
I mean being able to kill a region in a special way and yank it in columns. But the code you provided is already pretty useful. –  Alfred M. May 21 '12 at 6:22
    
Well, for that you have the usual rectangle commands -- in this case, C-x r k to kill a rectangular region, and C-x r y to paste it elsewhere. –  Eli Barzilay May 22 '12 at 2:00
    
I meant something similar to this usual command but with transposition. –  Alfred M. May 22 '12 at 5:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.