Search code examples
selectblockgoogle-colaboratorymultiline

How to do block select in Colab (also called vertical select / multiline edit)


It is feasible in Jupyter/Sublime text editor, and other places. How to do it within Colab?

I couldn't find anything in the documentation/shortcuts.


Solution

  • With Mouse:

    • Press Shift+Alt and then use the mouse

    With Keyboard:

    • Press Shift+Alt and then use the arrow keys to move*

    * In my system Shift+Alt+Left/Right will change desktop. But I found that in Colab, once I go up/down as needed (creating the multi-line selection) then I can release Alt and continue only with Shift and move horizontally as needed.

    Block selection in Colab

    Bonus:

    • Q: How to move up/down the selected text easily?

    • A:

      • If you just press Alt+Up/Down, the line you are in will move Up/Down
      • If you select some text and press Alt+Up/Down, that block will move Up/Down

    Moving selection up/down in Colab