- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想知道是否有办法让#region Some Region #endregion Some Region
。如果没有办法做到这一点,那么也许可以使用 Resharper?
希望大家清楚我要在这里实现的目标。
编辑:
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>#region</Title>
<Shortcut>#region</Shortcut>
<Description>Code snippet for #region</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Region name</ToolTip>
<Default>MyRegion</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[#region $name$
$selected$ $end$
#endregion $name$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
第二次编辑:它的工作,但只有当我制作插入片段时。从 intellisense 这使用我猜的其他一些片段。
那么有没有办法从智能感知而不是插入片段菜单添加我的区域?
最佳答案
如果你想要实现的是......
#region MyRegion
//...lots of code...
#endregion // end of MyRegion
您可以使用所谓的“SurroundsWith”片段来完成此操作。这是我图书馆的这样一个片段......
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippet Format="1.0.0"
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>Enregions a block of code</Title>
<Author>GJV</Author>
<Shortcut>enr</Shortcut>
<Description>Surrounds a block of code with region directives</Description>
<SnippetTypes>
<SnippetType>SurroundsWith</SnippetType>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>RegionName</ID>
<ToolTip>Region Name</ToolTip>
<Default>MyRegion</Default>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[#region $RegionName$$end$
$selected$
#endregion // end of $RegionName$]]>
</Code>
</Snippet>
</CodeSnippet>
要在 Visual Studio 中使用它,请将代码片段放入 .snippet 文件并将其保存在代码片段目录中,然后转到工具 => 代码片段管理器 => 添加。添加后,您可以使用标准 CTRK K+X 访问它。
与区域的内置代码片段相比,这唯一让您可以灵活地添加尾随注释以指示区域的结束。您还可以通过添加额外的扩展来进一步自定义它。
注意:标记 $end$ 标记操作完成后您希望光标停留的位置。
关于c# - 在#endregion 处自动创建同名的#region,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18122131/
您如何推荐使用#region/#endregion?这应该在多大程度上取代使用子函数来阐明您的代码? 最佳答案 完全没有。 首先,#regions 更像是一种将许多相关函数/成员分组到可折叠区域中的方
任何人都知道找出我的代码中哪里有额外的#region 或#endregion 的好方法吗?我有大约 5000 行 c# 代码,我现在正在尝试手动执行。感谢您的帮助。 最佳答案 执行 CTRL+M CT
我想知道是否有办法让#region Some Region #endregion Some Region。如果没有办法做到这一点,那么也许可以使用 Resharper? 希望大家清楚我要在这里实现的目
我正在使用 Roslyn 开发一个搜索代码库的小工具。一个功能是我可以搜索某个方法是否存在,如果存在,我将返回完整的方法文本以显示在 UI 上。 我正在使用集成了 Roslyn 的 Visual St
我知道我可以在 C# 中使用 #region #endregion 来包围代码 fragment ,在 Kotlin 中是否有类似的语法?谢谢! #region MyRegion pro
这对于组织和浏览代码非常有用。为什么没有实现?如果它会阻止某些构造,为什么不为 F# 提供类似的东西? 最佳答案 我同意代码折叠很好,我们需要在代码中添加注释,但是 我想要比 region/endre
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Java equivalent to #region in c# Java 中是否有一些东西可以像在 C#
如果我有以下内容 #region blah; blahblah; ..... moar; #endregion 如果我在屏幕上看到#endregion 标签,我如何跳转到顶部#region 标签? 有
我想使用像 #region/#endregion 这样的预处理器命令来组织我的 XML 数据,使其可以折叠和展开。 C#/.NET 中的命令。我正在编辑此文件 Visual Studio 2008。
我们在 TypeScript 中使用“区域折叠”已经有一段时间了,就像这样: //#region GUI handlers ...some code related to handling GUI e
我从事一个在 Windows、Mac 和 Linux 上运行的 C++ 项目。因此,一天在 Visual Studio 中处理同一部分代码、第二天在 Xcode 中、下一天在 Qt Creator 中
当用户使用“Implement Inteface X”上下文菜单功能时,插入的代码会被 包围 #region [interfacename] Members #endregion 一对。我总是最终删除
我是一名优秀的程序员,十分优秀!