简体   繁体   English

跳转到Visual Studio中的循环开始/结束快捷方式?

[英]Jump to loop start/end shortcut in Visual Studio?

Is there any keyboard shortcut I can use to go up to start of, for example, foreach loop which I'm editing at the moment? 我有什么键盘快捷键可以用来启动,例如,当前正在编辑的foreach循环吗? And maybe there is also a shortcut to go to the end of the loop? 也许还有一条捷径可以走到循环的尽头?

Maybe there is something like that when I'm using Resharper, if not in vanilla Visual Studio? 也许在我使用Resharper时(如果不是在普通的Visual Studio中)有类似的东西吗?

I'm not writing about debugging! 我不是在写调试! Just writing the code. 只需编写代码。

Sorry, but I can't find anything about this, but it seems like some basic functionality IDE should have... 对不起,但是我对此一无所获,但似乎IDE应该具有一些基本功能...

You can certainly jump between the braces. 您当然可以在括号之间跳转。 If you have your cursor either side of one of the braces (at the start or end of your loop) use CTRL + ] to jump to the other one. 如果光标位于其中一个括号的任一侧(在循环的开始或结尾),请使用CTRL + ]跳到另一个括号。 This will work on any set of braces, not just loops. 这将适用于任何一组花括号,而不仅仅是循环。

You can use Ctrl + ] : it 您可以使用Ctrl + ] :它

Moves the cursor to the matching brace in the document. 将光标移动到文档中匹配的括号。 If the cursor is on an opening >brace, this will move to the corresponding closing brace and vice versa 如果光标在右括号>上,它将移动到相应的右括号,反之亦然

Do you mean you want to move the cursor to the starting/ending bracket? 您是说要将光标移动到开始/结束括号吗? I don't know of one that does this, although you can collapse the loop to see both what happens before and after at the same time. 我不知道这样做是什么,尽管您可以折叠循环以查看之前和之后同时发生的情况。

although, to be fair, if your loop has so many lines that you can't see both brackets at the same time, it might be a good idea to make the code inside the brackets shorter (for example, with an extra method: 虽然,公平地说,如果循环中有太多行,导致您无法同时看到两个方括号,最好使方括号内的代码更短(例如,使用额外的方法:

foreach (string entry in entryList)
{
   AnalyseValue(entry);
}

您可以在特定的代码行( Ctrl + KCtrl + K )上创建书签,并导航到您的下一本书或上一书签(Next Bookmark => Ctrl + KCtrl + N )(Previous Bookmark => Ctrl + P

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM