8

Trying to copy selected text from a file opened in VI on google cloud shell and paste it in another shell tab. If I select the text in visual mode it wouldn't work. On a local terminal I would use xclip, or shift(+ctrl) before selecting.

Is there a way to achieve this?

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
abreschi
  • 581
  • 6
  • 10

1 Answers1

0

Assuming you're using Cloud Shell in the browser and not gcloud alpha cloud-shell ssh, you can simply select text with your mouse/cursor and it will copy it into your clipboard of the browser's OS. In normal or visual mode. See docs.

You then paste with middle click, shift+insert, ctrl+shift+v in Linux (assumption based on xclip reference).

YaguraStation
  • 558
  • 2
  • 12
  • It is true that for most applications, if you select text, it is automatically copied to the clipboard. However, the question was about ```vi```. The behavior seems different, and selected text isn't automatically copied. Not sure if the concept of selecting text even applies to ```vi```. – mherzog Nov 10 '20 at 13:50
  • Yeah, hence the distinction between using a browser (how I assume most people are using Cloud Shell) and `gcloud`. – YaguraStation Nov 11 '20 at 16:04