32

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?

14

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.

41

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.

  • 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 :) – Piotr Dobrogost Mar 30 '17 at 17:32
9

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.

6
  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. 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

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
    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 '16 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.