Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a sure-fire method to cut & paste word-wrap on X-based terminals? That is, if I select, then paste via button-3, if the text goes to the end of the line and wraps, the paste assumes carriage return and inserts it. I'd rather:

if (endcolumn==non-space character) {
  assume wordwrap
}
else {
  insert carriage return after last non-space character
}

This drives me crazy. Especially when pasting code that is > 80 columns. Sometimes it works, most of the time it doesn't.

share|improve this question
    
since the clicknpaste action is something that is controlled by the terminal .. which one do you use? –  akira Feb 11 '11 at 18:48
    
Most often I'm in gnome-terminal. –  Pete Ashdown Feb 14 '11 at 15:33

2 Answers 2

up vote 0 down vote accepted

I agree this makes a huge difference in usability. I find it very important to be able to triple-click and copy/paste lines which have wrapped. There are two ways this can work correctly. Either triple-click (and click drag) selects past the end of line onto the next visible line, with no CR inserted. Or else triple click selects only one visible line, but when you paste it, there is no CR.

The broken way is when triple-click selects only the visible line, and then it assumes a CR at the end when it pastes. I have seen bad behavior from xterm and gnome terminal. I've seen good behavior from Mac Terminal app, and from iTerm which is another Mac terminal app.

I have no hints for turning a bad situation into a good one other than trying a different terminal program. I'm certain this ties into whether the terminal program actually remembers the locations of all the CRs it sees, or whether it simply interprets the CR and then forgets it.

share|improve this answer

Unix terminals don't do word wrap. This is a feature of the application running inside the terminal. The terminal receives the same instructions to display

|This is text formatted  |        |This is line 1.         |
|to 24 columns           |   or   |This is line 2.         |

If you can, tell your application not to do any wrapping. This way the terminal will wrap, but always on the last column.

|This is a single long li|
|ne of text.             |

If you triple-click on this, you get This is a single long line of text with a newline only at the end (or no newline at all depending on the terminal emulator).

When pasting, the terminal just sends the text to the application, as if you had typed it. If you observe any behavior such as wrapping that depends on the terminal width, it's due to the application, not to the terminal.

share|improve this answer
    
You are right, this is not a function of terminals. Incidentally, KDE Konsole has functionality (that you can enable, in advanced) where triple-click selects only to the end of the line. This is really useful to grab a command after your prompt without having to grab the whole line. –  Jamieson Becker Nov 17 at 15:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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