File and Code Templates - how to set cursor at specific position

Hey,

is there any way to set cursor at specific point at File and Code Templates (like it's done in Live templates using $END$ variable)? Now cursor is set after the generated method.

 Enabling Live templates doesn't help 

4
10 comments

Hi there,

Try ${CARET}. Not sure at all if it will work in entries from "Code" tab -- it only seem to be available on "Files" and "Includes" tabs.

The main possible reason (as per my understanding) is that templates used here can be used in automatic code generation (e.g. you may choose to generate few methods at once; in such case "caret placed here" placeholder does not really makes much sense)

 

0

Thanks for the reply, though caret is not working.

 

But according to this issue  https://youtrack.jetbrains.com/issue/IDEA-45030 it has to be working ($END$ using live templates in File and Code Templates ).

Could it be possible that this feature become broken on some new releases? Cause the last comments are dated by year 2015

0

Please try that Live Template in templates in first 2 tabs.

As I have said -- that may simply never worked (and may not even has been planed to work) in templates in "Code" tab.

0

Also: https://youtrack.jetbrains.com/issue/IDEA-159930#comment=27-2428810 -- the only "not working $END$" mentioning I have found so far

0

Thanks, I'll vote for that issue.

0

Is there any update on this? It's still not working...

2

$END$ is working for me in PyCharm 2019.3.4 (Professional Edition).

2

any updates?

 

0

Elil, #[[$END$]]# is supposed to work in File Templates when the Enable Live Templates checkbox is checked, but it only works reliably on empty lines.
Does it not do the trick for you?

3

Eugene, you are right! Checkbox should be checked! Thanks a lot!!

1

Please sign in to leave a comment.