Friday, October 5, 2012

eclipse keyboard shortcuts

Press Ctrl+Shift+L for the list of shortcuts, we can then press Ctrl+Shift+L again to get taken us straight to the 'General/Keys' section of Windows/Preferences i.e. Press Ctrl+Shift+L twice.

Ctrl + Alt + Down arrow: copies current line or selected lines to below

Ctrl + Alt + Up arrow: copies current line or selected lines to above

To escape text when pasting into a String literal automatically:
Go to Window -> Preferences -> Java -> Editor -> Typing
The following window will be displayed:



Check "Escape text when pasting into a string literal" option as shown in the above image.

Use of above trick: Assume, we are pasting absolute path to a file on Windows.
Example: C:\folder1\folder2\file.txt
With the above trick while pasting the above path into a String literal it becomes
"C:\\folder1\\floder2\\file.txt"