Is it possible to replace to upper case in Visual Studio using "Find and Replace" dialog and RegEx (?) à la: . => Upper(.)
?
在Visual Studio中使用“查找和替换”对话框和RegEx (?)= >上部(。)?
Say I have:
我有说:
m_<b>a</b>blabla
I want:
我想要:
_<b>A</b>blabla
2 个解决方案
#1
22
You can solve this by using Visual Studio temporary macros. This is a very powerful, flexible feature which I use all the time for performing repetitive code manipulations.
您可以通过使用Visual Studio临时宏来解决这个问题。这是一个非常强大、灵活的特性,我一直使用它来执行重复的代码操作。
I'm assuming you're using the C# default key bindings here.
我假设您在这里使用c#默认键绑定。
- Press CTRL+SHIFT+F to bring up the find in files dialogue.
- 按CTRL+SHIFT+F打开“文件发现”对话框。
- Click use "Regular expressions"
- 点击使用“正则表达式”
- Set "Find what:" to "
<m_:Ll
" - words that begin with m, underscore, then a lower case letter; -
Set "Find what:" to "
"> - Click "Find all" to search for all occurrences;
- 点击“查找所有”,搜索所有发生的事件;
- Press CTRL+SHIFT+R to start recording temporary macro;
- 按CTRL+SHIFT+R开始录制临时宏;
- Press F8 to find next occurrence of search expression;
- 按F8查找下一个出现的搜索表达式;
- Press right cursor, right cursor, SHIFT + right cursor (to skip "m_" and then select the lower case letter);
- 按右光标、右光标、SHIFT +右光标(跳过“m_”,选择小写字母);
- Press CTRL+SHIFT+U to uppercase the lower case letter;
- 按CTRL+SHIFT+U将小写字母大写;
- Press CTRL+SHIFT+R to stop recording temporary macro;
- 按CTRL+SHIFT+R停止录制临时宏;
- Press CTRL+SHIFT+P to replay temporary macro, which will jump to next expression and uppercase the first letter after the "m_". You need to press CTRL+SHIFT+P as many times as there are expressions.
- 按CTRL+SHIFT+P重新播放临时宏,该宏将跳转到下一个表达式,在“m_”后面的第一个字母大写。你需要按CTRL+SHIFT+P,按多少次就按多少次。
#2
7
No, Visual Studio does not support that. For a reference of the regular expressions capabilities in VS check:
不,Visual Studio不支持这个。关于VS检查的正则表达式功能的参考:
Regular Expressions (Visual Studio)
正则表达式(Visual Studio)
(Original answer, given due to misinterpreting the original question)
(原答案,由于对原问题的误解而给出)
Assuming Visual Studio C# Default key bindings.
假设Visual Studio c#默认的键绑定。
There are different ways you can achieve this.
有不同的方法可以实现这一点。
If it's a (variable, method, property, etc) you can use the Rename refactoring to change all instances. This refactoring is invoked by pressing F2 key while on the instance you want to rename.
如果是(变量、方法、属性等),可以使用Rename重构修改所有实例。在要重命名的实例上,通过按F2键来调用这个重构。
If you perform the change on the definition itself you can also use SHIFT+ALT+F10 to invoke the active refactorings popup and then do the rename all instances.
如果对定义本身执行更改,还可以使用SHIFT+ALT+F10调用活动重构弹出,然后重命名所有实例。
If it's a string literal you can use the shortcut CTRL+U (lowercase) and CTRL+SHIFT+U (uppercase) to rapidly switch the case of the selection. This is valid for all text shown in the editor, but most useful for string literals.
如果是字符串文字,你可以使用快捷键CTRL+U(小写)和CTRL+SHIFT+U(大写)来快速切换选择的情况。这对于编辑器中显示的所有文本都是有效的,但是对于字符串常量来说最有用。
#1
22
You can solve this by using Visual Studio temporary macros. This is a very powerful, flexible feature which I use all the time for performing repetitive code manipulations.
您可以通过使用Visual Studio临时宏来解决这个问题。这是一个非常强大、灵活的特性,我一直使用它来执行重复的代码操作。
I'm assuming you're using the C# default key bindings here.
我假设您在这里使用c#默认键绑定。
- Press CTRL+SHIFT+F to bring up the find in files dialogue.
- 按CTRL+SHIFT+F打开“文件发现”对话框。
- Click use "Regular expressions"
- 点击使用“正则表达式”
- Set "Find what:" to "
<m_:Ll
" - words that begin with m, underscore, then a lower case letter; -
Set "Find what:" to "
"> - Click "Find all" to search for all occurrences;
- 点击“查找所有”,搜索所有发生的事件;
- Press CTRL+SHIFT+R to start recording temporary macro;
- 按CTRL+SHIFT+R开始录制临时宏;
- Press F8 to find next occurrence of search expression;
- 按F8查找下一个出现的搜索表达式;
- Press right cursor, right cursor, SHIFT + right cursor (to skip "m_" and then select the lower case letter);
- 按右光标、右光标、SHIFT +右光标(跳过“m_”,选择小写字母);
- Press CTRL+SHIFT+U to uppercase the lower case letter;
- 按CTRL+SHIFT+U将小写字母大写;
- Press CTRL+SHIFT+R to stop recording temporary macro;
- 按CTRL+SHIFT+R停止录制临时宏;
- Press CTRL+SHIFT+P to replay temporary macro, which will jump to next expression and uppercase the first letter after the "m_". You need to press CTRL+SHIFT+P as many times as there are expressions.
- 按CTRL+SHIFT+P重新播放临时宏,该宏将跳转到下一个表达式,在“m_”后面的第一个字母大写。你需要按CTRL+SHIFT+P,按多少次就按多少次。
#2
7
No, Visual Studio does not support that. For a reference of the regular expressions capabilities in VS check:
不,Visual Studio不支持这个。关于VS检查的正则表达式功能的参考:
Regular Expressions (Visual Studio)
正则表达式(Visual Studio)
(Original answer, given due to misinterpreting the original question)
(原答案,由于对原问题的误解而给出)
Assuming Visual Studio C# Default key bindings.
假设Visual Studio c#默认的键绑定。
There are different ways you can achieve this.
有不同的方法可以实现这一点。
If it's a (variable, method, property, etc) you can use the Rename refactoring to change all instances. This refactoring is invoked by pressing F2 key while on the instance you want to rename.
如果是(变量、方法、属性等),可以使用Rename重构修改所有实例。在要重命名的实例上,通过按F2键来调用这个重构。
If you perform the change on the definition itself you can also use SHIFT+ALT+F10 to invoke the active refactorings popup and then do the rename all instances.
如果对定义本身执行更改,还可以使用SHIFT+ALT+F10调用活动重构弹出,然后重命名所有实例。
If it's a string literal you can use the shortcut CTRL+U (lowercase) and CTRL+SHIFT+U (uppercase) to rapidly switch the case of the selection. This is valid for all text shown in the editor, but most useful for string literals.
如果是字符串文字,你可以使用快捷键CTRL+U(小写)和CTRL+SHIFT+U(大写)来快速切换选择的情况。这对于编辑器中显示的所有文本都是有效的,但是对于字符串常量来说最有用。