visual-studio Visual Studio - 是否有选择整行的键盘组合?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2732098/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:52:27  来源:igfitidea点击:

Visual Studio - Is there a keyboard combination to select an entire line?

visual-studiovisual-studio-2008visual-studio-2010keyboard-shortcuts

提问by Albert

I already know about Ctrl+ Lto delete an entire line...is there one to just select an entire line (which I can then copy and paste somewhere else...)

我已经知道Ctrl+L删除整行......是否有一个只选择整行(然后我可以复制并粘贴到其他地方......)

回答by Task

You can also use Ctrl+ Xto cut an entire line. Similarly, you can use Ctrl+ Cto copy an entire line.

您还可以使用Ctrl+X来剪切整行。同样,您可以使用Ctrl+C复制整行。

As long as you don't have anything selected, the command will work on the entire line.

只要您没有选择任何内容,该命令就会在整行上工作。

回答by Jacob Saylor

Hit

  • Home
  • Shift+ End
  • Home
  • Shift+ End

回答by fOcusWow

You can do it with Shift+ DownArrow.

你可以用Shift+做到这一点DownArrow

回答by ramushasha

Yes there is. If you are in the begining of the line press Shift+ End. If you are in the end of the line press Shift+ Home. Hope that helps

就在这里。如果您在行首,请按 Shift+End。如果您在行尾,请按 Shift+Home。希望有帮助

回答by Bala R

I believe, if you don't have any selection and press Ctrl+ C, it would copy the line.

我相信,如果您没有任何选择并按Ctrl+ C,它会复制该行。

回答by facebook-10206909618965949

Shift+ End= Select between cursor and the end of the line

Shift+ End= 在光标和行尾之间选择

回答by sbi

It's Home+Home, then Shift+Downfor me.

它是Home+ Home,然后是Shift+Down对我来说。

Or you change that settingwhich makes Ctrl+Cwith no selection copy the line. But I hate that, so I always turn it off. (Thanks to Bala for providingthe link to that setting!)

或者您更改该设置,使Ctrl+C没有选择复制该行。但我讨厌它,所以我总是把它关掉。(感谢 Bala提供该设置的链接!)

To cuta line, Ctrl+Lworks in my keyboard settings.

剪断一条线,Ctrl+L在我的键盘设置中起作用。

回答by Dax Fohl

There's also Alt-Upand Alt-Downto move whole lines. It's two fewer keystrokes than using Ctrl-X, and unlike Ctrl-X, it also moves multiple whole linesat a time if your selection covers multiple lines even partially. It's also nice because the feedback is instantaneous, unlike Ctrl-Xwhere you can never remember whether the pasted line will go above or below your cursor.

还有Alt-UpAlt-Down移动整行。它比使用少两次击键Ctrl-X,并且与 不同Ctrl-X,如果您的选择甚至部分覆盖多行,它还会一次移动多整行。这也很好,因为反馈是即时的,这与Ctrl-X您永远无法记住粘贴的行是在光标上方还是下方的情况不同。

I saw this and thought I'd never use the feature. But once I got used to it I use it all the time. There's no easier way to move a block of code than using Shift-Up/Downto select the lines, press Alt-Up/Downa few times to move them, and then use Tabto adjust the indentation.

我看到了这一点,并认为我永远不会使用该功能。但是一旦我习惯了它,我就会一直使用它。移动代码块没有比使用Shift-Up/Down选择行、按Alt-Up/Down几下移动它们,然后使用Tab调整缩进更简单的方法了。

Of course it only works within the same file though.

当然,它只能在同一个文件中工作。

回答by Mark Wilkins

Visual Studio macros are another way to do these types of operations if you can't find an existing command. A simple way to create one is:

如果找不到现有命令,Visual Studio 宏是执行这些类型操作的另一种方法。创建一个的简单方法是:

  • Use the Record TemporaryMacro option (under Tools/Macros).
  • Select the line however you prefer (e.g., home, shift, end).
  • Click Stop Recording (under Tools/Macros).
  • Choose Save TemporaryMacro (under Tools/Macros).
  • Then choose Tools/Customize/Keyboard and assign a shortcut to the macro.
  • 使用 Record TemporaryMacro 选项(在工具/宏下)。
  • 选择您喜欢的线路(例如,home、shift、end)。
  • 单击停止录制(在工具/宏下)。
  • 选择保存临时宏(在工具/宏下)。
  • 然后选择工具/自定义/键盘并为宏指定快捷方式。

回答by nick4eva

I use Ctrl+ Insertto copy entire line, and Shift+ Insertto paste entire line.

我用Ctrl+Insert来复制整个产品线,并Shift+Insert粘贴整条生产线。