Home Articles Books Download FAQs Tips

Code Editor: Column based cutting and pasting

ALT + SHIFT + arrow keys // selects a column of text using the keyboard
ALT + LEFT MOUSE CLICK   // selects a column of text using the mouse
CTRL + C                 // copies the column to the clipboard
CTRL + V                 // pastes the column into the editor
LEFT MOUSE CLICK         // returns to non-column based selection

When you select text in the Code Editor, the selection is normally based on rows. If you hold down the ALT key while you make the selection, the Code Editor will select the text in columns instead of in rows. Figure 1 and Figure 2 illustrate the difference between selecting rows of text, and selecting columns of text.




Figure 1. Selecting rows of text




Figure 2. Selecting columns of text using the ALT key


Selecting a column of text is amazingly useful. You can delete a column of text very quickly. For example, column based selection makes it very easy to delete the variable Table1 from each line of code in Figure 2. Use the ALT to select Table1 in each line of code. Then we can press the DEL key to delete the selected column of text.

Note: Once you enter column based selection mode, you stay in that mode until you left click in the code editor somewhere (or you use the CTRL+O+K shortcut, see last note below). The left click returns you to row based selection.

Note: Pasting text in column mode works differently that it does in the normal row selection mode. When you paste text in column mode, the Code Editor automatically moves down to the next line after inserting text. This comes in handy when you need to paste the same text in multiple rows.

For example, let's say that we wanted to paste the text DataModule1-> in front of each line of code in Figure 2. You can quickly do this by typing DataModule1-> in front of the first line of code. Next, hold down the ALT key and highlight the text DataModule1->. Hit CTRL + C to copy the text the clipboard. After copying the text to the clipboard, move to the next line and press CTRL + V to paste. After inserting the text, the Code Editor moves to the next line. Now you can simply press CTRL + V a handful of times until each line has DataModule1-> in front of Table1.

Note: Here is another handy pointer. You can use column based selection when you indent code with CTRL+SHIFT+I. If you highlight a column of text and indent with CTRL+SHIFT+I, only the column of text, and all text to the right of the column, moves over. The text to the left of the selected column does not move.

Note: The code editor provides keyboard shortcuts that allow you to toggle between column mode and normal mode. In the default keymapping, the shortcuts are:

CTRL + 0 + C // switches to column mode
CTRL + 0 + K // switches back to normal mode
CTRL + O + L // switches to line based mode (selection consumes entire lines)
CTRL + O + I // switches to inclusive mode (same as CTRL+O+K)

The CTRL+O+K shortcut is especially handy. If you select a column with ALT+SHIFT+arrow keys, you can return to normal mode with the CTRL+O+K shortcut. This is more convenient than reaching for the mouse.



Copyright © 1997-2001 by Harold Howe.
All rights reserved.