Denise
Denise

Reputation: 1469

Keyboard shortcuts in Eclipse

Is there a way to change a shortcut in Eclipse that when I press that shortcut Eclipse will write some line of code? Let's say I press Ctrl+Shift+P would it be possible that Eclipse will write <p></p>?

Thanks

Upvotes: 3

Views: 682

Answers (2)

cthulhu
cthulhu

Reputation: 3169

As far as I know, no, but as aioobe answered, you can use templates for it. Instead of that keyboard combo, you'd instead type something like par Ctrl+Space to get Eclipse's autosuggest for creating an paragraph open / close tag (with the cursor in the middle). This'll either display a dropdown if Eclipse is unsure, or just chuck your template down if it has no doubts.

Note also that, when editing HTML files (or anything XML~like), you can get Eclipse to auto-close tags, so typing <p> will automatically add a closing tag too. This might of course be a bit trickier due to the Shift+< keyboard combo's (depending on your finger's agility and, possibly, keyboard configuration). I have no trouble with it though.

Upvotes: 1

aioobe
aioobe

Reputation: 420921

Have a look at the templates support.

WindowPreferencesJavaEditorTemplates

Here is an article describing custom eclipse templates.

Upvotes: 5

Related Questions