visual-studio 使用键盘快捷键浏览代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1888161/
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
Navigating through code with keyboard shortcuts
提问by Marcelo
I'm starting to feel the need to run fastly through code with keyboard shortcuts, to arrive faster where I want to make any changes (avoiding use of mouse or long times holding ↑, ←, →and ↓).
我开始觉得有必要通过与键盘快捷键码快速度运行,更快地到达我想要做任何更改(避免使用鼠标或长时间的持有↑,←,→和↓)。
I'm already using some:
我已经在使用一些:
Home- first position in current line
End- last position in current line
Ctrl+ Home- first line of the entire code
Ctrl+ End- last line of the entire code
Page Up- same vertical position, one screen above
Page Down- same vertical position, one screen below
Ctrl+ Page Up- first line in current screen
Ctrl+ Page Down- last line in current screen
Ctrl+ ←/ →- skipping word per word
Home- 当前行的第一个位置
End- 当前行的最后一个位置
Ctrl+ Home- 整个代码的第一行
Ctrl+ End- 整个代码的最后一行
Page Up- 相同的垂直位置,上方一屏
Page Down- 相同的垂直位置,下方一屏
Ctrl+ Page Up- 当前屏幕的第一行
Ctrl+ Page Down- 当前屏幕的最后一行
Ctrl+ ←/ →- 每个单词跳过单词
What have you got ?
你有什么 ?
I use Visual Studio. (but I'm open to any answer, as I maybe can use others soon)
我使用 Visual Studio。(但我对任何答案都持开放态度,因为我可能很快就会使用其他答案)
obs: I've searched through stackoverflow and didn't find a nice question with this content, nor a list of keyboard code searching. If it's repeated, I'm sorry for not finding it, I'm here in my best intentions.
obs:我在 stackoverflow 中搜索过,但没有找到有关此内容的好问题,也没有找到键盘代码搜索列表。如果它重复,我很抱歉没有找到它,我在这里是出于最好的意图。
This question is NOT about any shortcuts, and not only about visual studio, it's about running through code with shortcuts.
这个问题与任何快捷方式无关,不仅与视觉工作室有关,还与使用快捷方式运行代码有关。
Answers that suit the question so far:
到目前为止适合该问题的答案:
Ctrl+ -- jumps to last cursor position
Ctrl+ Shift+ -- jumps to next cursor position
Ctrl+ F3- Jumps to next occurance of the word the curson is in
Shift+ F3- Same as the above, backwards.
F12- Goes to definition of method/variable the cursor is in
Ctrl+ ]- Jumps to matching brace and select
Ctrl+ -- 跳转到最后一个光标位置
Ctrl+ Shift+ -- 跳转到下一个光标位置
Ctrl+ F3- 跳转到光标所在单词的下一次出现
Shift+ F3- 同上,倒退。
F12- 转到光标所在的方法/变量的定义
Ctrl+ ]- 跳转到匹配的括号并选择
I'll ad more as there are answers.
当有答案时,我会做更多的广告。
采纳答案by Heinzi
For Visual Studio, Ctrl+ -is priceless (jump to last position).
对于 Visual Studio,Ctrl+-是无价的(跳到最后一个位置)。
回答by Ben Collier
Ctrl+ F3to find the next occurrence of whatever word your cursor is inside of. So if you clicked on the first instance of the word 'occurrence' in my post and pressed Ctrl+ F3, it would take you down to the second one.
Ctrl+F3查找光标所在的任何单词的下一次出现。因此,如果您在我的帖子中单击“发生”一词的第一个实例并按Ctrl+ F3,它会将您带到第二个。
回答by Pete McKinney
I use a lot of keyboard shortcuts in Visual Studio, and also a lot of Alt-key menu navigation.
我在 Visual Studio 中使用了很多键盘快捷键,还有很多 Alt 键菜单导航。
Ctrl/ ShiftF3to repeat search, search backwards
Ctrl/ShiftF3重复搜索,向后搜索
CtrlF3to search for the current word.
CtrlF3搜索当前词。
F12to jump to the definition of the current word.
F12跳转到当前词的定义。
CtrlFto open the search window
CtrlF打开搜索窗口
Ctrl]to jump to a matching brace
Ctrl]跳转到匹配的大括号
ShiftCtrl]to jump to a matching brace and select
ShiftCtrl]跳转到匹配的大括号并选择
I also find I tend to use the ALT-key to navigate the menus. Because you can see the underlines, it makes it easy to learn. example: Alt-EFI(Edit/Find and Replace/Find in Files) takes you to Find in Files. Alt-Lthen takes you to the scoping drop down. 3 arrow keys takes it to Find in Solution, or 4 takes it to Find in Project.
我还发现我倾向于使用 -ALT键来导航菜单。因为您可以看到下划线,所以很容易学习。例如:Alt- EFI(编辑/查找和替换/在文件中查找),带您在文件中查找。 Alt-L然后带你到范围下拉菜单。3 个箭头键将它带到在解决方案中查找,或 4 个将它带到在项目中查找。
There's also the bookmarking shortcuts- CTRLKKto toggle a bookmark, CTRLKLto clear them all, CTRLKNfor the next and CTRLKPfor the previous.
还有书签快捷方式CTRLKK- 切换书签,CTRLKL清除所有书签,CTRLKN下一个和CTRLKP上一个。
Some of the people I work with really like regions, but I don't, so CTRLMLopens all the regions up. However, I do like to use CTRLMMto collapse a section of code. It's really handy to collapse the current method, select the collapsed method and copy the whole thing to the clipboard. CTRLMOwill collapse everything to definitions, which occasionally is nice.
与我一起工作的一些人非常喜欢区域,但我不喜欢,所以CTRLML打开所有区域。但是,我确实喜欢使用CTRLMM折叠一段代码。折叠当前方法,选择折叠方法并将整个内容复制到剪贴板真的很方便。 CTRLMO将所有内容折叠为定义,这有时很好。
回答by doug65536
Alt + Up Arrowand Alt + Down Arroware amazing commands. They move lines up and down. Saves a ton of keystrokes and you don't have to clobber your clipboard. It even works for multi-line selections.
Alt + Up Arrow并且Alt + Down Arrow是惊人的命令。他们上下移动线。节省了大量的击键次数,而且您不必破坏剪贴板。它甚至适用于多行选择。
Alt + Shift + Arrow keyallow you to make a block selection. What many don't know is, if you have a vertical block selection (with zero width) and type, it will type into all the lines at the same time. Extremely useful.
Alt + Shift + Arrow key允许您进行块选择。许多人不知道的是,如果您有一个垂直块选择(宽度为零)和类型,它将同时输入所有行。非常有用。
If you wish to populate several lines with the same thing you can put it on the clipboard, make a vertical block selection across multiple rows, and paste into all the rows at the same time. This can also work to append to several rows at once, pasting into a selection that is to the right of the existing text.
如果您希望用相同的内容填充多行,您可以将其放在剪贴板上,在多行中进行垂直块选择,然后同时粘贴到所有行中。这也可以一次附加到多行,粘贴到现有文本右侧的选择中。
Ctrl+Deldeletes next word. However, if there is space after the cursor, it deletes all the space. Usually what you want when you have the cursor in the right place and the text is off to the right and that next word needs to be pulled over to the cursor.
Ctrl+Del删除下一个单词。但是,如果光标后有空格,则会删除所有空格。通常,当您将光标放在正确的位置并且文本位于右侧并且需要将下一个单词拉到光标上时,您想要什么。
Ctrl+Backspacedeletes the previous word. Not particularly useful, but it's a good under-utilized shortcut. I see people mashing backspace all the time.
Ctrl+Backspace删除前一个单词。不是特别有用,但它是一个很好的未充分利用的快捷方式。我看到人们一直在捣鼓退格。
Although not strictly a keyboard shortcut, if you hold Altand click somewhere in the text editor, it will force the cursor to be there. If you type it will automatically put in spaces or tabs appropriately to make that text be there.
虽然严格来说不是键盘快捷键,但如果您按住Alt并单击文本编辑器中的某处,它会强制光标停留在那里。如果您键入,它会自动适当地放入空格或制表符以使该文本在那里。
回答by rosscj2533
F12= Go To Definition of method/variable cursor is in. Works well combined with Heinzi's Ctrl+ -answer to view definition of method then quickly go back to where you were using it.
F12= Go To Definition of method/variable cursor is in. 与 Heinzi 的Ctrl+ -answer结合使用效果很好,可以查看方法定义,然后快速返回到您使用它的地方。
回答by DOK
You can find over 100 answers to this very same question here:
您可以在此处找到相同问题的 100 多个答案:
回答by ResharperUsr
Alt+ ↑, Alt+ ↓
Alt+ ↑, Alt+↓
Will jump to next, previous code block (Method, class, etc.) Might only be in ReSharper.
将跳转到下一个、前一个代码块(方法、类等)可能只在 ReSharper 中。
回答by the_e
Honestly, I long for the day when VisVim gets to a good enough point to get me to buy it for Visual Studio (<3 VI keyboard commands).
老实说,我渴望有一天 VisVim 达到足够好的程度,让我为 Visual Studio 购买它(<3 个 VI 键盘命令)。
Anyway, the command that I use the most in Vis Studio is Ctrl+ D, which I have mapped to Edit.GotoFindCombo
无论如何,我在 Vis Studio 中使用最多的命令是Ctrl+ D,我已经映射到Edit.GotoFindCombo
回答by dxh
On Visual Studio, but using a lot of the ReSharper shortcuts. A few that I use heaps:
在 Visual Studio 上,但使用了大量 ReSharper 快捷方式。我使用堆的一些:
Ctrl+ N- Go to type
Ctrl+ Shift+ N- Go to file
Ctrl+ Shift+ Alt+ N- Go to symbol
Ctrl+ F12- Go to method (in current file)
Ctrl+ B(or Ctrl+ Click) - Go to declaration
Ctrl+ Shift+ T- Go to type declaration
Alt+ F7- Find usage (or go to usage, if only one)
Ctrl+ N- 转到类型
Ctrl+ Shift+ N- 转到文件
Ctrl+ Shift+ Alt+ N- 转到符号
Ctrl+ F12- 转到方法(在当前文件中)
Ctrl+ B(或Ctrl+ 单击)- 转到声明
Ctrl+ Shift+ T- 转到类型声明
Alt+ F7- 查找用法(或转到用法,如果只有一个)
For the first four, resharper gives me a dropdown menu with options, filtered as I type, and they all support wildcards (*), and camel-hump navigation (typing SPIfilters to just items such as SinglePassengerInfo, etc)
对于前四个,resharper 为我提供了一个带有选项的下拉菜单,在我输入时进行过滤,它们都支持通配符 ( *) 和驼峰导航(将SPI过滤器输入到诸如 SinglePassengerInfo 等项目)

