55

I use Midnight Commander (MC) editor over putty to edit files

I want to know how to copy text from one file, close it then open another file and paste it?

If it is not possible with Midnight Commander, is there another easy way to copy and paste specific text from different files?

9 Answers 9

24

I would do it like this:

  1. switch to block selection mode by pressing F3
  2. select a block
  3. switch off block selection mode with F3
  4. press Ctrl+F which will open Save block dialog
  5. press Enter to save it to the default location
  6. open the other file in the editor, and navigate to the target location
  7. press Shift+F5 to open Insert file dialog
  8. press Enter to paste from the default file location (which is same as the one in Save block dialog)

NOTE: There are other environment related methods, that could be more conventional nowadays, but the above one does not depend on any desktop environment related clipboard, (terminal emulator features, putty, Xorg, etc.). This is a pure mcedit feature which works everywhere.

72

To copy: (hold) Shift + Select with mouse (copies to clipboard)

To paste in windows: Ctrl+V

To paste in another file in PuTTY/MC: Shift + Ins

Other hotkeys here.

Midnight Commander tutorial here.

2
  • 3
    If you get unwanted indents in what was pasted then while editing file in Midnight Commander press F9 to show top menu and in Options/Generals menu uncheck Return does autoindent option. Yes, I was happy when I found it too :) Mar 30, 2017 at 17:32
  • 3
    Shift + Mouse right click works as Paste - it even faster if you are working with mouse
    – Lixas
    Apr 3, 2021 at 12:46
12
  1. Hold down the Shift key, and drag the mouse through the text you want to copy. The text's background will become dark orange.
  2. Release the Shift key and press Shift+Ctrl+c (or Ctrl+Insert). The text will be copied.
  3. Now you can paste the text to anywhere you want by pressing Shift+Ctrl+v, even to the new page in MC.
1
  • How do you select more than one screen of text? Sep 23, 2022 at 17:37
11

IF you're using putty in either Xorg or Windows (i.e terminal within a gui) , it's possible to use the "conventional" right-click copy/paste behavior while in mc. Hold the shift key while you mark/copy.

4

According to help in MC:

Ctrl+Insert copies to the mcedit.clip, and Shift+Insert pastes from mcedit.clip.

It doesn't work for me, by some reason, but by pressing F9 you get a menu, Edit > Copy to clipfile - worked fine.

0

Putty has ability to copy-paste. In mcedit, hold Shift and select by mouse

1
  • 1
    LOL - did you actually read the other answers? And your answer is incomplete, you should include what to do with the mouse in order to "select by mouse".
    – mcii-1962
    Jun 20, 2016 at 23:01
0

If you are editing within mcedit, and you wish to copy some text that is within the file itself, put your cursor at the start of the text you wish to copy.

then hold shift and select the text you want to have copied. When all to be copied text is highlighted release shift and move your cursor where it should be inserted. Then hit F5.

the highlighted text will be inserted at the cursor location.

0

This command will watch mcedit.clip for changes with entr and copy text to clipboard with xclip:

find ~/.local/share/mc/mcedit -name mcedit.clip | entr xclip -i -sel clip ~/.local/share/mc/mcedit/mcedit.clip &

It works for long lines where Shift+Mouse fails.

0

If it is not possible with Midnight Commander, is there another easy way to copy and paste specific text from different files?

I, as author of putty4far2l putty fork, suggest you to try «far2l + putty4far2l» for similar to «mc + putty» user expirience, but with full clipboard support via commonly used Shift/Ctrl+Ins/Del and Ctrl+C/V/X key combinations. This software pair allows two clipboard modes: isolated, then your host and remote server uses different clipboards, and synced, then the same clipboard is used. You will be asked to choose on first clipboard access.

PS: ppa for far2l is here, putty4far2l's binary is available directly on github

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .