Reputation: 81
I'm wondering whether it's possible to configure PyCharm so that it will insert a line of code upon pressing some keyboard shortcut. Ideally it would write: console.log(); where the cursor is and move the caret within the brackets. I've been going through the keymappings but couldn't find anything of that sort. Thanks in advance.
Upvotes: 0
Views: 142
Reputation: 4921
Have you checked Live Templates? From official documentation:
Live templates let you insert frequently-used or custom code constructs into your source code file quickly, efficiently, and accurately.
Basically, you can create some abbreviation, which will be expanded in the editor to whatever you want. Furthermore, you can let your cursor to be in required position, using $END$ macros.
For example, for console.log
you can create live template like this:
console.log($END$)
And name it for example cl. Now when you enter cl
in the editor, it would suggest you to expand it to configured live template.
Upvotes: 1