in Emacs, edit multiple lines at once
I believe textmate has a mode where if you start typing, the same thing will be entered on all the lines you've selected. Is there something similar to this in emacs? I'm guessing there's a way rectangles can help me, but I'm not sure how...
It's as simple as this: C-x r t
Some examples are here: http://ergoemacs.org/emacs/emacs_string-rectangle_ascii-art.html
You absolutely need to try installing multiple cursors:
https://github.com/magnars/multiple-cursors.el
It's in marmalade and melpa so just:
M-x package-install multiple-cursors
One of the solutions is using CUA mode. Activate cua mode with M-x cua-mode
, select rectangle begin: first press C-Enter
then move cursor with standard movement commands to make selection, now pressing enter at any time will cycle cursor through corners of the rectangle enabling you to prepend or append text to the selection.
You can use the following commands (and keys) to accomplish this:
- open-rectangle (C-x, r, o) add spaces
- kill-rectangle (C-x, r, k) delete
- clear-rectangle (C-x, r, c) replace with spaces
- M-x string-insert-rectangle fill with specified text
Here is a complete description of those features: http://www.gnu.org/software/emacs/manual/html_node/emacs/Rectangles.html