skip to Main Content

So imagine I have mutiple lines of variable and their definitions in multiple lines like this (for example in flutter) :

 TypeA a;
 TypeABCD abcd;
 Typ abcdefghijklmnopqrstuwxyz;

now I want to select all of the types together or all of the variables together; I know how to select multiple line together in vscode but the problem is in this case it does not cover the specific selection of them or it selects them partly because they have different lengths. how can I select multiple variables or types or whatever in this case?

imagine what I want to select is:

a 
abcd 
abcdefghijklmnopqrstuwxyz 

how can I do that?

or this:

TypeA
TypeABCD
Typ

3

Answers


  1. You can press "option" on Mac or "ctrl" on other OS to navigate cursor by word and not character.

    So the trick is to do multi-cursor on each line then use word navigation to select what you want – press Ctrl + Shift + -> for example to select first word in each line even if words are of different length.

    Its pretty hand and I use even more complex tricks to be productive, hope this helps.

    Below is video showing the same.
    https://drive.google.com/file/d/1mrw3jyhk6NEtWg4Y5p7eK5dCPCnbA8ln/view?usp=drive_link

    Sample image
    enter image description here

    Login or Signup to reply.
  2. You could hold the Alt key and drag you mouse cursor vertically from the beginning of those lines to a put a cursor on every of those lines.

    Then press Ctrl+right arrow to jump to the next word in those lines

    Then Ctrl+Shift+Right arrow to select those words

    Login or Signup to reply.
  3. With a cursor on one of the lines, use AltShift⏶/⏷ to get a cursor on every line.

    Then:

    • To select variables: End, , CtrlShift

    • To select types: Home, CtrlShift

    If the types are not single words for the purposes of ctrl+arrows, you could instead do something like:

    • End, , Ctrl, , CtrlShiftHome
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search