[英]In IntelliJ, is there a shortcut to get variable I've already typed to be a parameter in a method I want to type?
Suppose I have this code:假设我有这个代码:
var x = 2;
var y = x;
Then I realize that I actually wanted this:然后我意识到我实际上想要这个:
var y = someMethod(x);
To accomplish this, first I need to position the cursor to the left of "x", then type "someMethod(", then move my cursor to the right, and then add the final ")".要做到这一点,首先我需要 position cursor 到“x”的左边,然后输入“someMethod(”,然后移动我的 cursor 到右边,然后添加最后的“)。
What I'd love is to have a way to, say, highlight "x", and have it automatically get inserted as a parameter to whatever I start typing.我喜欢的是有一种方法来突出显示“x”,并让它自动作为参数插入到我开始输入的任何内容中。
Is there something for this in IntelliJ?在 IntelliJ 中有什么东西吗?
Put the cursor at the left of x
, start typing the method name and wait for the autocompletion sugestions to appear (if they don't press CTRL+Space), find your method in the list, select it with keyboard arrows, and press ENTER.将 cursor 放在
x
的左侧,开始输入方法名称并等待自动完成提示出现(如果他们没有按 CTRL+空格键),在列表中找到您的方法 select 用键盘箭头,然后按 ENTER . IDEA will automatically use x
as the parameter of the mthod. IDEA 会自动使用
x
作为 mthod 的参数。
Try using Statement Completion :尝试使用语句完成:
x
x
前Ctrl + Shift + Enter
Ctrl + Shift + Enter
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.