Is it possible to have Introduce Local variable as a context action at end of line?

已回答

I have the following code:

os.Open("pages/index.html")

If my cursor is at the `Open` part, `Introduce Local Variable` is a context action, and I can generate the prefix like below:

file, err := os.Open("pages/index.html")

But it is not an option if my cursor is at the end of the line, is there any way to configure this? This works in Java code in IntelliJ.

0
正式评论

Hi,

Please see this comment about quick-fix and how it works now in GoLand.

You can use Command+Option+V (Ctrl+Alt+V) shortcut to introduce variable at the end of the line. Also, you can type .var after the expression you want and stay in the flow without having to invoke a refactoring.

I hope it helps.

请先登录再写评论。