Книга: Learning GNU Emacs, 3rd Edition

7.5.1 CUA Rectangle Editing

7.5.1 CUA Rectangle Editing

If you are familiar with CUA mode, which is part of Emacs starting with 21.3.5, you may know that it provides cut and paste key sequences familiar to Windows users, as in C-x to cut and C-v to paste (see Chapter 13). The second most commonly touted feature of CUA mode is its superior rectangle support.

We've just looked at a myriad of rectangle commands. CUA's rectangle support is far simpler. By learning essentially one command, you can cut and paste rectangles in CUA mode.

Unfortunately at present, CUA mode support is standard but not nuanced on Emacs 21.3.5. You either take the whole enchilada or you don't. To turn it on, select C-x/C-c/C-v cut and paste (CUA) from the Options menu. If you don't generally like to use the CUA keybindings for cut and paste, you might turn this option on only when you are doing rectangle editing.

To select a rectangle, type Shift-Enter. Emacs starts to highlight in a dark pink color by default. You extend the highlighting with normal cursor movement keys (the mouse does not work at present).

Move to the C in Cell and type: Shift-Enter


The upper-left corner of our rectangle is marked (Windows).

The minibuffer displays an array of CUA mode rectangle commands. For now, we'll just mark the rectangle and experiment with one of these commands momentarily.

Move the cursor to the last number in Alvin's phone number.


The rectangle is marked (Windows).

Note that the marked rectangle isn't strictly rectangular in shape. The phone numbers form a true rectangle, but in order to create a rectangle that includes the column header, we need to ask CUA mode to "pad" the rectangle using M-p, one of the commands listed in the minibuffer earlier.

Type: M-p


The pad command makes this a true rectangle (Windows).

We can now cut or paste the rectangle using C-x or C-v respectively. This is just a taste of the CUA mode rectangle commands. You can explore more of them on your own. We thought you should be aware of this method as an alternative to the more keyboard-intensive rectangle commands that have been part of Emacs for many years.

Оглавление книги

Оглавление статьи/книги

Генерация: 0.081. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз