I got a comment in my last post regarding dragging a line up and down. I remembered that I once started working on a minor mode "drag stuff". Whatever happened to that I don't know.
Having a few hours to spare this weekend I decided to create the mode. The mode is called drag-stuff-mode. The source is at Github.
First download the source from Github and make sure it's in Emcacs load-path. Then require it. A more detailed installation description is given in the README and lisp source file.
First off, start the mode with M-x drag-stuff-mode. Note that all command takes a prefix argument to repeat the command that many times.
To drag a line, put the cursor on that line and press
For example, put the cursor on line 3 and press
class Foo
end
attr_accessor :bar
You should now have
class Foo
attr_accessor :bar
end
Drag lines work like drag line except for that you can move more than one line. Note that you don't have to select the complete lines. It's enough that some part of the first and last lines are selected.
Mark the to_s method and press
def to_s
":#{bar}:"
end
class Foo
end
You should now have
class Foo
def to_s
":#{bar}:"
end
end
You can drag a region left and right by selecting a region and press
For example. Select {bar} and press
class Foo
def to_s
{bar}":#:"
end
end
You should now have
class Foo
def to_s
":#{bar}:"
end
end
To drag a word, just place the cursor on the word and press
Put the cursor on me and press
class Foo
def to_s
"drag me to the right"
end
end
You should now have
class Foo
def to_s
"drag to the me right"
end
end
There are obviously more things you can drag. These were what I came up with. If you think that my selection is stupid and I should change something, leave a comment with a good reason an I'll see what I can do! ;)