|
|
Tor Olav Kristensen wrote:
> Invisible wrote:
>> Tor Olav Kristensen wrote:
>>> Invisible wrote:
>>> ...
>>>> Or you have a grid of numbers, and you want to add another column in
>>>> the middle. Or stuff like that. Since Emacs == Lisp, it seems that
>>>> you could probably spend 20 minutes writing some code that would do
>>>> what you want.
>>> ...
>>>
>>>
http://www.gnu.org/software/emacs/manual/html_node/emacs/Text-Based-Tables.html#Text-Based-Tables
>>
>>
>>
>> Close, but not quite what I was thinking of.
>>
>> I was thinking more like you have some text such as
>>
>> case x of
>> 5 -> return [(1, 4), (2, 3)]
>> 6 -> return [(1, 5), (2, 4), (3, 3)]
>> 7 -> return [(1, 6), (2, 5), (3, 4)]
>>
>> and you suddenly decide you need to change that to
>>
>> case x of
>> 5 -> return $ Just [(1, 4), (2, 3)]
>> 6 -> return $ Just [(1, 5), (2, 4), (3, 3)]
>> 7 -> return $ Just [(1, 6), (2, 5), (3, 4)]
>>
>> It's kinda tedious to do this by hand. (Depending on just how many
>> times you need to do it, obviously...)
>
> Have a look at this:
>
> http://www.gnu.org/software/emacs/manual/html_node/emacs/Rectangles.html
>
> (The text cursor is the "point" and you can put a "mark" in the text
> with C-space.)
So here's what you could do:
M-g g // goto-line
2 // 2
C-right // forward-word
C-right // forward-word
C-space // set-mark-command
down // next-line
down // next-line
C-x r t // string-rectangle
$ Just //
--
Tor Olav
http://subcube.com
Post a reply to this message
|
|