21

How to copy and paste text in MongoDB shell?

I tried Ctrl+C and Ctrl+V but it didn't work.

Thanks, Michael.

Penny Liu
  • 15,447
  • 5
  • 79
  • 98
Michael Horojanski
  • 4,543
  • 4
  • 33
  • 34
  • 1) just select the text in shell , then right click and choose copy then copy the text 2) right click and choose paste option – karthi Apr 03 '17 at 08:45
  • 2
    It depends on the context; what kind of _terminal program_ are you running the mongo shell in? The windows command prompt? A unix shell? Putty? Powershell on windows? – Vince Bowdren Apr 03 '17 at 12:22
  • The windows command prompt – Michael Horojanski Apr 03 '17 at 13:56
  • unable to do so in google cloud mongo shell – DEEPAN KUMAR Nov 18 '18 at 10:21
  • Everyone seems to be giving instructions on how to get hotkey paste to work in a Windows console. I have no problems with doing a hotkey paste to work in a Windows console or in a Powershell console - so long as Mongo isn't running. It's only when the Mongo shell is running in the console that paste doesn't work. – Jeff Dege Oct 09 '20 at 15:36
  • Right-clicking by itself seems to copy if text is selected and paste if text isn't selected, rather than opening a context menu. – user7868 Aug 28 '21 at 02:35

12 Answers12

24

If you are using Windows then Command:

Copy = Ctrl + Insert
Paste = Shift + Insert

This works for Windows as well as Linux:

1. Select your text using Mouse
2. Press Mouse-Right button to Copy & Paste
3. Press Mouse-Right button to Paste copied text from Clipboard
Gadhia Reema
  • 186
  • 3
  • 17
csharpbd
  • 3,786
  • 4
  • 23
  • 32
7

For Windows:

Copy: Right-click anywhere in the command prompt window, then click Mark. Click the beginning of the text you want to copy. Press and hold down the SHIFT key, and then click the end of the text you want to copy (or you can click and drag the cursor to select the text). Either right-click the title bar, point to Edit, and then click Copy OR press Enter.

Paste: Position the cursor where you want the text to be inserted: Right-click and then click Paste.

enter image description here

chridam
  • 100,957
  • 23
  • 236
  • 235
4

This is what I did:

I ran mongo shell on the command line to have access to my databases. I wanted to add some data to a collection. I wrote the code in a text editor. Then I tried to use CTRL+C and CTRL+V but mongo shell did not accept it.

So instead I RIGHT CLICKED on the command line TAB, CLICKED on EDIT, then CLICKED on PASTE.

I hope this helps.

Please see image gif here

gif

Sumanth
  • 159
  • 2
  • 15
Walter Clayton
  • 141
  • 2
  • 7
2

If you want to copy external text to mongo shell , try Right-Mouse click to paste the text. The Right click directly copies the text.

RAMAN BHATIA
  • 397
  • 2
  • 5
  • 17
2

Right Click TAB Command Edit Paste

That's it

Khai Lim
  • 41
  • 2
2
  1. write your shell command in any other text editor. (notepad , sublime , vscode etc).

  2. select your command and then right click and select copy .

  3. now go to your mongodb shell and just right click your command should be pasted.

---------------------------------- Happy Coding ------------------------------------

1

Most of them check the properties but those properties have to be set to default otherwise it won't work, to make the properties default, in order to make the QuickEdit work by default or all the time follow the below steps.

Right-click on the tab click Defaults, in the Defaults screen->Options Tab and check QuickEdit Mode, Check this image for clarity.

Make sure to check QuickEdit Mode in Options tab

img]

Note: click Defaults not Properties

Sumanth
  • 159
  • 2
  • 15
1

Right-click on the tab click Defaults, in the Defaults screen->Options Tab and go to EDIT OPTIONS and then check the (Use Ctrl+Shift+C/V), Check this image for referenceenter image description here.

0

Using mongo version 4.0 on windows.

Try removing the tabs from the text you want to paste and then right click in the shell and the text should be pasted.

Copying from the shell works fine by selecting and pressing Ctrl + C

0

It seems that windows CMD deactivates Quick edition option if an error is risen. Error can occur if mongo command is large enough to overflow CMD buffer. If insertMany command is used buffer size and buffer # have to be increased.

So verify if this properties-options-quick Edit is checked event if it has been done yet.

best regards

Paul L
  • 1
  • 1
0

For Windows Mongo shell pasting and Marking: normal copy from source then paste in shell by right clicking in shell title (white border) bar at top then selecting EDIT in drop down then select paste. You can also copy "MARK" with this process.

0

From the mongo shell or the windows command prompt, right-click on the prompt header, navigate to properties, check the option 'Use Ctrl + Shift + C/V as Copy/Paste' - follow through to copy, paste.

ggv
  • 11
  • 1
  • 1
  • 3