There has already been a post in stackoverflow for VI editor for copying all the text into the clipboard. (Copy all the lines to clipboard) I want to do the same thing with the less
viewer. I tried to search online for the process called "yank" and I did not find anything for it.
How do I copy all lines in the less editor into the clip board.
And I cannot close less and reopen it in vi. It is because of the fact that I have managed to load this file into the editor and while I have loaded it, the file has already been moved in the back end. It is a long story. The easiest solution for me now is to copy the contents of the file into memory.
Press y to copy, or d to cut the selection. Move the cursor to the location where you want to paste the contents. Press P to paste the contents before the cursor, or p to paste it after the cursor.
You can repurpose less's 'v' command for this. When less runs, press 'v' to open the present file in the $EDITOR; in this case, open it with xsel -ib < {the file's name} . Using xsel -ib puts the data on the clipboard, so you can ctrl-V to paste the data where you want it.
CTRL A means "Mark the entire file. CTRL C means "Copy the selection.
In vim command mode press v , this will switch you to VISUAL mode. Move the cursor around to select the text or lines you need to copy. Press y , this will copy the selected text to clipboard. Go to any external application and CMD + v to paste.
less
doesn't have a clipboard, but you may be able to get it to output what's stored in its buffers to a new file. This will only work if the entire contents of the file are buffered:
dd of=/path/to/new/file
and press Enter
The dd
command will take the piped data and save it to the file passed to the of=
argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With