Search code examples
emacsterminal-emulator

Is there a way to make regions in term modes respect line wrapping?


When using a term mode derivative (like ansi-term or multi-term), I often want to select a region and copy it someplace else. If that region includes a line which wraps at the edge of the terminal window, pasting that region in another buffer always inserts a hard newline at the place where term wrapped the line. This means I often have to go back and clean up pasted text. Is there a way to avoid doing this? I tried both term-line-mode and term-char-mode; both do the same thing.

I do not want to write a yank hook which strips out all newlines, since I want to preserve existing hard newlines in the original content.


Solution

  • This works for me:

    (setq term-suppress-hard-newline t)