Eclipse Feature Highlight: Block Selection Mode

If you are using Eclipse for Java Developers and came across the issue that you want to remove a vertical block in a text file the block selection mode may help you.

Eclipse block selection

To start the block selection mode in Eclipse on macOS press Alt plus Cmd and A. The mouse cursor will change to a cross and now you can select a block in the text file. The text file can be anything from Java code, XML or just plain text files.

Once you made your selection either press delete on your keyboard to remove the block or start typing and what you type will appear in all the selected lines at the beginning of your block selection.

Ideas to use this feature

Quickly create CSV files for testing purposes

Open a new text file, insert ten empty lines and make a block selection from line one to ten. Then start typing “abc,123,def” and you end up with a simple CSV file that you can use in your unit tests. Maybe add the column headers at the top, change a few lines to randomize the contents a bit and you’re all set.

Add HTML child elements

If you have a HTML table and want to add five columns to a row you could type <td></td> as a placeholder and copy / paste it four more times. Instead you can enter five empty lines, make a block selection from line one to five and then start typing <td></td>.

Remove unwanted blocks from console output

Logging output often prefixes every line with a timestamp. If you need to copy the remaining text from a few lines of logging output without these timestamps just copy the relevant lines to a text editor in Eclipse, enter the block selection mode, select the beginning of the lines and press delete.