18

Another answer: use M-x picture-mode. You can kill or copy rectangles through the middle of tab chars etc., send them to registers, etc.


10

The extend-rectangle-to-end function in the rectangle-utils package is what you want. It's on melpa. It inserts spaces to make the current rectangle selection extend to cover the longest line in the region. To get this behaviour, I've got this in my init.el. C-x r e is not bound to anything else in vanilla emacs (require 'rectangle-utils) (global-set-key ...


10

As another answer suggests, you can insert 90 new lines using prefix argument 90 like this: C-u 90 RET. Then insert the number list using C-u C-x r N as you did. However, if you want a more flexible format of numbered list, you can use Keyboard Macro counter. I included some exercises in my guide. Here is one: Exercise 1: Creating incremental header ...


9

Here is a solution: (defun mouse-start-rectangle (start-event) (interactive "e") (deactivate-mark) (mouse-set-point start-event) (rectangle-mark-mode +1) (let ((drag-event)) (track-mouse (while (progn (setq drag-event (read-event)) (mouse-movement-p drag-event)) (mouse-set-point drag-event))))) (...


8

Use M-x picture-mode. C-c C-y, bound to command picture-yank-rectangle, does what you want. (You can use C-_ to undo.) These related keys are also available in picture-mode: C-c C-k - Clear a rectangle and save it (picture-clear-rectangle) C-c C-w - Clear a rectangle and save it in a register (picture-clear-rectangle-to-register) C-c C-x - Like C-c C-y, ...


8

My crystal ball tells me you're using Emacs-24.5, which indeed had this limitation. This has been fixed in Emacs-25 where rectangle-mark-mode has been improved so you can move the cursor past the "end" of a line (and where you can use C-x C-x to go to another corner of the rectangle as well).


7

Tu Do's answer is very good and well worth remembering for custom counter formatting, but potentially (depending on the actual use-case) a little excessive for this particular example, given that %d is the default format for the counter. The output can therefore be achieved like so: M-1F3F3RETM-9M-0F4


7

It's tiny's time to shine: m\n90 will expand (with tiny-expand) to what you want. There's also rich formatting and templating that can be applied. m5|%02d: 00 01 02 03 04 05 m7|%(expt 2 x): 1 2 4 8 16 32 64 128 m1\n5|*** TODO http://emacsrocks.com/e%02d.html: *** TODO http://emacsrocks.com/e01.html *** TODO http://emacsrocks.com/e02.html *** TODO ...


6

You can use a numeric argument to avoid typing RET 90 times. Just do M-9 0 RET to insert 90 newlines. Alternatively, you can write a simple function that creates a range of numbers and loops over them using number-sequence and dolist: (defun insert-numbers (start end) (interactive "nStart: \nnEnd: ") (dolist (ind (number-sequence start end)) (...


6

If I understood your question, your are looking to something like this: (defun youngfrog/copy-rectangle-to-kill-ring (start end) "Saves a rectangle to the normal kill ring. Not suitable for yank-rectangle." (interactive "r") (let ((lines (extract-rectangle start end))) (with-temp-buffer (while lines ;; insert-rectangle, but without the ...


5

Perhaps the prerelease versions you were building had the version number 24.4.50? That means that they're actually prerelease versions of 24.5, which was later renamed to 25.1 (but still not released at the time of this writing). If so, you actually downgraded to the release version of 24.4, and thus lost this feature. I'm currently running 25.0.50, and ...


5

Here is a one-off command you can use to yank the each line of the current kill on the end of each subsequent line, starting on the current line. (defun yank-append-lines (&optional without-space) "Yank each line of the current kill at the end of each subsequent line. A space will be added between each line unless WITHOUT-SPACE which can be passed in ...


5

You can also achieve this using shell-command-on-region and the Unix utility cut. Highlight the region. Press C-u M-|, enter "cut -d= -f1", press RET. The prefix argument C-u tells shell-command-on-region to replace the region with results. If you don't want to (or can't) modify the current buffer, you can still use M-| (now without the prefix argument). In ...


5

Actually for org-table-copy-region it isn't necessary to mark the exact column width! Just mark the beginning of the column somewhere in a cell, then the end by going down the required number of rows and do C-c C-x M-w (for M-x o-t-c-r). Then go to another cell, where you want to add the column and do C-c C-x C-y (for M-x org-table-paste-rectangle).


4

Using Org-mode Select the text of the table. C-c | Add at the bottom: #+TBLFM: $6=$6+5.487 and press C-c C-c while the point is either on the formula or on the table. This gives: | ATOM | 10 | H5 | LIG | 1 | 4.803 | 2.034 | 0.000 | 1.00 | 0.00 | | ATOM | 11 | C1 | LIG | 1 | 6.461 | 0.686 | 0.000 | 1.00 | 0.00 | | ATOM | 12 | H1 | LIG | 1 | 7.221 | 1....


3

In the general case, what you want cannot be achieved. This is because several utilities and modes in Emacs store their read-completion history in different variables, not in one location. You can manually set those history variables to nil (for your C-x r t example, (setq string-rectangle-history nil)), but it doesn't scale. It's also not easy to ...


3

Don't use C-x r t (string-rectangle), use C-x r k (kill-rectangle) instead.


3

CUA's help on rectangles (and other things) is slightly hidden away. M-x find-library RET cua-base RET Search the commentary for the section on "CUA rectangle support" (Which is not to suggest that library commentaries in general are "hidden" -- they're a crucial aspect of Emacs' documentation which all users should know how to access. It's just that in ...


3

Not sure what is special about having the rectangle in the kill-ring, but if you upgrade to Emacs-24.4, then you can do: C-x SPC .... M-w to select a rectangle and place it on the kill-ring. After that C-y will yank that rectangle (in the same was that C-x r y does, tho).


3

You can always use M-x query-replace-regexp, if you're comfortable with regexps and elisp. Replacing: ^\(\(?:[^ ]+ +\)\{5\}\)\([ -][0-9.]+\) With: \1\,(format "% .3f" (+ 5.487 \#2)) Will replace the second captured group (being the 6th column) with the formatted result of the calculation. This will break the alignment slightly if the numbers get too ...


3

You can use multiple cursors to get this done. Before you get started with the below steps, add this to your init.el, evaluate it and bind it to a key binding of your linking. ;; http://stackoverflow.com/questions/3035337/in-emacs-can-you-evaluate-an-emacs-lisp-expression-and-replace-it-with-the-resul (defun eval-and-replace-last-math-sexp () "Replace an ...


3

Removing yank-handler text property from just killed text should do the trick, since this will make yank use normal insert instead of rectangle-mark-mode's own insert function. (defun kill-ring-save--strip (orig-fun &rest args) (let ((rtv (apply orig-fun args))) (if rectangle-mark-mode (let ((killed (car kill-ring))) (remove-text-...


3

I usually do this by moving point to the end of the last line in the block, just as you have described, but then I insert spaces at the end of the line until point is in the last column that I want to cut. Then C-x r k cuts the entire rectangle; spaces will be added to the ends of any lines that are shorter than the width of the block.


2

Just for the sake of diversity: C-x * c (Starts the calculator). 1RETv b90RET creates a vector 90 elements long. V U + calls to accum Calc function which acts similar to reduce, putting the intermediate results into positions of the elements which generate those. At this point you have a vector which looks like [1, 2, .... 89, 90]. Copy the vector into the ...


2

C-x r t should still work in 24.4 just as in 24.3. You can get the same functionality from C-x SPC by hitting C-t after you've selected the rectangle of interest.


2

For this particular case, it looks like you can just replace \([0-9]\),\([0-9]\) with \1\2. That will leave the commas in the second column alone because all of those are followed by spaces. If you didn't have spaces in the second column, you could still replace \([,0-9]+\) |$ with | \,(replace-regexp-in-string "," "" \1) | This hits only the last column ...


2

It feels as if the combination of the multiple-cursors and iy-go-to-char packages is to do exactly this kind of stuff. First of all, if you don't have those packages installed, they can be installed via MELPA. Select all the lines you need and then do M-x mc/edit-lines (or the default binding C-S-c C-S-c). Move all the cursors to the beginning of the lines (...


2

A common solution in general is to use artist-mode (I'm even wondering whether you accidentally tried picture-mode instead of this?) In Emacs 25, rectangle-mark-mode has been improved such that you can do this by default, after invoking that with C-xSPC For usage details, see C-hig (emacs) Rectangles In Emacs 24 the cua-selection-mode rectangle editing (...


2

The two commands org-table-select-col and org-table-copy-col in the following lisp code allow the selection and the copying of the current table column. You can bind it to the key of your liking and/or insert it via easy-menu-define-key into org-tbl-menu. (defun org-table-goto-col-beginning () "Go to beginning of current column and return `point'." (...


2

You don't need a rectangle for this job. Just use (query-replace-regexp "[ ]+" "\n") to replace the separating spaces by linebreaks. The corresponding key-sequence is: C-M-% [ ]+ RET C-q C-j RET Meaning: C-M-% query-replace-regexp [ ]+ the regular expression for the strings to be replaced (one or more spaces) C-q next character is inserted literally (...


Only top voted, non community-wiki answers of a minimum length are eligible