is there a way to get auto-completion inside comment string literals?

Quite often when writing comments or log messages I mention class/method names, like "method <Bla> says hi", and I often wish that R# would offer auto-completion.

Obviously I don't expect full intellisense (since, you know, the code isn't compilable), but at least hippie-completion (https://www.jetbrains.com/help/idea/auto-completing-code.html#hippie_completion) would be nice. Sublime Text does it, and every time I'm like "wow that's convenient!"

And maybe it shouldn't be automatic, but explicitly invoked with the usual keyboard shortcuts (alt+right arrow).

1
2 comments

You could use an interpolated string with the nameof operator:

$"Method {nameof(Bla)} says hi"

You'll get full intellisense within the placeholder. And if you rename the method, the string will automatically be updated to match.

0

Yes, I forgot to mention it initially but I know about nameof, it's great in some cases but not as straightforward and lo-tech (requires string concatenation which would occur at runtime, unless the compiler detects this case and inlines it?).

Also, that's not applicable to comments.

0

Please sign in to leave a comment.