Reputation: 1469
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
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
Reputation: 420921
Have a look at the templates support.
Window → Preferences → Java → Editor → Templates
Here is an article describing custom eclipse templates.
Upvotes: 5