简体   繁体   English

在每行开头使用光标选择多行

[英]Select multiple lines with cursors at each line start

I want to select multiple lines and put a cursor at the beginning of each line.我想选择多行并将光标放在每行的开头。 Sublime Text can do this with Ctrl - Shift - L select multiple lines Sublime Text 可以使用Ctrl - Shift - L选择多行

ctrl + shift + L and then put cursor at beginning of each line ctrl + shift + L 然后将光标放在每行的开头

Press Crtl + Shift + Alt + Arrow up/down to select multiple lines in Visual Studio Code.Crtl + Shift + Alt +向上/向下箭头以在 Visual Studio Code 中选择多行。 Note that the selected lines will be in one column (if possible).请注意,选定的行将在一列中(如果可能)。

You can also mark some lines and then do this combination and you have all selected lines included.您还可以标记一些行,然后执行此组合,您将包含所有选定的行。

Moreover you can press and hold Alt and click the lines you need.此外,您可以按住Alt并单击所需的行。 This way you can select multiple lines that are not neighbours or in the same column.这样,您可以选择不相邻或不在同一列中的多条线。

To do exactly what Ctrl - Shift - L does in Sublime Text, you must do:要完全执行Ctrl - Shift - L在 Sublime Text 中所做的事情,您必须执行以下操作:

On Windows:在 Windows 上:

  1. Select the lines.选择线条。

  2. Alt - Shift - I (will add multiple cursors) Alt - Shift - I (将添加多个光标)

  3. Shift - Home (will go at the beginning of each line and be selected) Shift - Home (将在每行的开头并被选中)

On Mac :在 Mac 上:

  1. Select the lines.选择线条。

  2. alt - shift - I (will add multiple cursors) alt - shift - I (将添加多个游标)

  3. cmd - shift - (will go at the beginning of each line and be selected) cmd - shift - (将在每行的开头并被选中)

More information in this answer .此答案中的更多信息。

  1. Put cursor at beginning of first line将光标放在第一行的开头
  2. Ctrl - Shift - Alt - Arrow down/up will put a cursor at the beginning of the following/preceding lines Ctrl - Shift - Alt -向下/向上箭头将光标置于以下/前一行的开头

  3. Ctrl - I will select those lines with the cursor at the beginning of each line. Ctrl -将在每行的开头使用光标选择这些行。

NOTE : On my vscode the cursors look like they might be shifted down one line but they actually are not - the are in the right place.注意:在我的 vscode 上,光标看起来可能会向下移动一行,但实际上并非如此——它们位于正确的位置。 If you start typing, it works but you have to hit Enter when you are done to get back separate lines.如果您开始输入,它可以工作,但您必须在完成后按 Enter才能返回单独的行。 It is a little quirky but works as you would expect.这有点古怪,但可以按您的预期工作。

EDIT (using a hint from @Maxime's answer)编辑(使用来自@Maxime 答案的提示)

  1. Select your test first.首先选择您的测试。
  2. Alt - Shift - I : puts cursors at the end of each of those lines but text unselected (I as in island not a lowercase L) Alt - Shift - I :将光标放在每一行的末尾,但未选择文本(I 在island中不是小写 L)
  3. Function - Home : put cursors at beginning of each line.功能- Home :将光标放在每行的开头。
  4. Ctrl - I : selects all lines. Ctrl - I :选择所有行。

Important: read the NOTE above.重要提示:阅读上述注意事项。

--------------------- v1.43 see How to put the cursor at the end of all selected lines in Visual Studio Code? --------------------- v1.43请参阅如何将光标置于 Visual Studio Code 中所有选定行的末尾? with column selection mode it is easy to put the cursor at the beginning or end of lines selected by dragging.使用列选择模式,很容易将光标放在通过拖动选择的行的开头或结尾。

You can hold alt and click the places you need with the mouse.您可以按住alt并用鼠标单击所需的位置。 This way you can select rows that aren't related, like row 10,15,18.这样您就可以选择不相关的rows ,例如第 10、15、18 行。 Also you can select at different places in the same row.您也可以在同一行的不同位置进行选择。

I hope this helps someone, but there is a setting in VSCode called Editor: Multi Cursor Modifier which may do what OP is asking:我希望这对某人有所帮助,但是 VSCode 中有一个名为Editor: Multi Cursor Modifier的设置可能会满足 OP 的要求:

编辑器:多光标修改器设置

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

相关问题 将多个光标添加到VSCode(Windows)中的行首? - Add multiple cursors to the start of line in VSCode (Windows)? Visual Studio Code中的CSS-选择多行并在选择中分别注释每行 - CSS in Visual Studio Code - Select multiple lines and comment each line within selection separately Vscode 停止多行光标跳到最后一个字符后的行首 - Vscode stop multiline cursors to jump to start of line after last character VS Code 多光标 - 重复粘贴单行 - VS Code Multiple Cursors - Paste Individual Lines Repeatedly 如何在 VSCode 中在每次查找结果时设置多个游标 - How to Set Multiple Cursors in VSCode at Each Find Result 有没有一种方法可以在VSCode中的不同组之间选择多个游标? - Is there a way to select multiple cursors between different groups in VSCode? select 使用多个光标时单词的下一次出现 - select next occurence of a word when using multiple cursors Visual Studio 代码 - 如何为 html 注释多行(每行而不是整个块) - visual studio code - how to comment multiple lines for html (each line instead whole block) 在多行上输出,我需要将每一行分配给它自己的变量 - Outputting on multiple lines and I need each line to be assigned to its own variable 为多行添加不同数量的空格,以便每行具有相同数量的字符 - Add different number of spaces to multiple lines so that each line has equal amount of characters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM