在Visual Studio中反转分配方向 [英] Invert assignment direction in Visual Studio

查看:118
本文介绍了在Visual Studio中反转分配方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio中有一堆分配操作,并且我想将它们逆转: 即

I have a bunch of assignment operations in Visual Studio, and I want to reverse them: i.e

i = j;

会变成

would become

j = i;

即用等号之后的内容替换等号之前的所有内容,反之亦然

i.e. replacing everything before the equals with what's after the equals, and vice versa

有什么简单的方法可以做到这一点,在正则表达式引擎中说些什么?

Is there any easy way to do this, say something in the regular expression engine?

干杯,埃德

推荐答案

选择要交换的行,按Ctrl + H,然后替换:

Select the lines you want to swap, Ctrl+H, then replace:

{:i}:b*=:b*{:i};

具有:

\2 = \1;

将查找范围:"设置为选择"

with "Look in:" set to "Selection"

尽管(通过:i")仅处理C/C ++样式标识符.替换为:

That only handles C/C++ style identifiers, though (via the ":i"). Replace that with:

{.*}:b*=:b*{.*};

替换"="两侧的任何内容.

to replace anything on either side of the "=".

此外,由于您在注释中提到使用ReSharper,因此只需突出显示"=,Alt + Enter和反向分配"即可.

Also, since you mentioned in a comment you use ReSharper, you can just highlight the "=", Alt+Enter, and "Reverse assignment".

这篇关于在Visual Studio中反转分配方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆