在 Visual Studio IDE 中是否有交换/重新排序参数的快捷方式?
在 IDE 中使用代码时,我遇到一个常见问题:
string.Concat("foo", "bar");
我需要将其更改为:
string.Concat("bar", "foo");
通常我有几个需要立即交换的代码。我想避免所有打字。有没有办法自动执行此操作?如果我知道从哪里开始,那么快捷方式或某种宏都会很棒。
编辑:更改为 string.Concat 以表明您不能总是修改方法签名。我只想更改方法调用中参数的顺序,而不是其他。
I have a common issue when working with code in the IDE:
string.Concat("foo", "bar");
and I need to change it to:
string.Concat("bar", "foo");
Often I have several of these that need to be swapped at once. I would like to avoid all the typing. Is there a way to automate this? Either a shortcut or some sort of macro would be great if I knew where to start.
Edit: changed to string.Concat to show that you can't always modify the method signature. I am only looking to change the order of the params in the method call, and nothing else.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
+
+
将调换两个单词,因此它适用于您的情况。不幸的是,对于具有较大参数列表的函数,我认为这不起作用(无需多次按下)...<Ctrl>
+<Shift>
+<t>
will transpose two words, so it would work in your case. Unfortunately I don't see this working (without multiple presses) for functions with larger parameter lists...我有很多带有这个函数的代码:
而且我只需要交换前两个参数;
我最终使用了一些具有正则表达式管理功能的文本编辑器(例如 Scite),并使用了这个节省了我的时间:
I had a lot of code with this function:
And I needed to swap only the first two parameters;
I ended up using some text editor with regular expression management (like Scite), and using this one saved me hours:
我使用的扩展程序恰好可以完成这一件事。
它描述自己为
https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.shifter
I use an extension that does exactly this one thing.
It describes itself as
https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.shifter