简体   繁体   中英

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? 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?

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...

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. This will work on any set of braces, not just loops.

You can use Ctrl + ] : it

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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