Eclipse line shortcuts

You can only have one thing in your clipboard, right ?

So you end up having to paste somewhere temporarily to avoid overwriting your clipboard content…you lose time and you mess up your files with temporary pastes that you forget to clean up…

There are other ways. If you want to clone a block of lines and move it somewhere nearby, proceed this way:

  1. Select the block of lines by pressing Shift + Arrow up/down.
  2. Press Ctrl + Alt + Arrow down, this will clone the block of lines.
  3. Move the lines where you want them: Alt + Up/Down.

You may still think copy & paste is faster, but notice how these shortcuts are similar, if you put your fingers on Alt and Ctrl and the up/down arrows you can combine them very quickly. It gets even faster for a single line.

In addition to that I would recommend using Ctrl + D for quickly removing lines and Ctrl + Shift + C to comment/uncomment lines. There are many other shortcuts,  but it does not make much sense to list them without giving a use case, simply press Ctrl + Shift + L.

There are various Multi clipboard tools/plugins, but I do not like depending on those.

Conclusion

This is very similar to copy & pasting, but it allows you to keep your clipboard content where you would normally not. These shortcuts can prove very effective when combined.

Related posts

Advertisements

2 thoughts on “Eclipse line shortcuts

  1. Not so useful, ctrl+c + ctrl+v is enough for me.

    You say yourself you don’t want to depend on plugins but you depend on IDE, it’s nearly the same. Changing to IntelliJ would prolly confuse you and your acquired reflexes while POCV (plain old ctrl+c ctrl+v :D) is common.

    • Of course you can still use Ctrl + c and Ctrl + v and I use them when appropriate. But if you reason that way you may not want to use any standard Eclipse shortcuts at all.
      It is only a side benefit that you do not need to use copy & paste, it is simply faster and more accurate to use these shortcuts in many cases.
      Cloning is often appropriate when you have a series of similar lines like request.setAttribute(“…”, …), you simply clone the initial line and modify it without doing any copy & paste.
      You can also quickly cut a line in two by pressing Enter, then press Ctrl + D to remove the second part or Alt + Arrow up/down to move it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s