visual-studio 是否可以在 Visual Studio 中替换为大写?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2743836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to replace to uppercase in Visual Studio?
提问by serhio
Is it possible to replace toupper case in Visual Studio using "Find and Replace" dialog and RegEx (?) à la: . => Upper(.)?
是否可以在 Visual Studio 中使用“查找和替换”对话框和 RegEx (?) à la:替换为大写. => Upper(.)?
Say I have:
说我有:
m_<b>a</b>blabla
I want:
我想:
_<b>A</b>blabla
采纳答案by RickL
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+Fto bring up the find in files dialogue.
- Click use "Regular expressions"
- Set "Find what:" to "
<m_:Ll" - words that begin with m, underscore, then a lower case letter; - Click "Find all" to search for all occurrences;
- Press CTRL+SHIFT+Rto start recording temporary macro;
- Press F8to find next occurrence of search expression;
- Press right cursor, right cursor, SHIFT+ right cursor (to skip "m_" and then select the lower case letter);
- Press CTRL+SHIFT+Uto uppercase the lower case letter;
- Press CTRL+SHIFT+Rto stop recording temporary macro;
- Press CTRL+SHIFT+Pto replay temporary macro, which will jump to next expression and uppercase the first letter after the "m_". You need to press CTRL+SHIFT+Pas many times as there are expressions.
- 按CTRL+ SHIFT+ F,弹出文件对话的发现。
- 单击使用“正则表达式”
- 将“查找内容:”设置为“
<m_:Ll” - 以 m、下划线和小写字母开头的单词; - 单击“查找全部”以搜索所有出现的情况;
- 按CTRL+ SHIFT+R开始录制临时宏;
- 按F8查找下一次出现的搜索表达式;
- 按右光标、右光标、SHIFT+右光标(跳过“m_”然后选择小写字母);
- 按CTRL+ SHIFT+U将小写字母大写;
- 按CTRL+ SHIFT+R停止录制临时宏;
- 按CTRL+ SHIFT+P重播临时宏,它会跳转到下一个表达式和“M_”后首字母大写为。您需要按CTRL+ SHIFT+ 的P次数与表达式的数量相同。
回答by Jo?o Angelo
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)
(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 F2key while on the instance you want to rename.
如果它是(变量、方法、属性等),您可以使用重命名重构来更改所有实例。F2在要重命名的实例上按键可以调用此重构。
If you perform the change on the definition itself you can also use SHIFT+ALT+F10to 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(大写)快速切换选择的大小写。这对编辑器中显示的所有文本都有效,但对字符串文字最有用。

