Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have text files with lines that of length greater than my terminal width. I generally use less to view these files and often want to copy something that wraps from one line to the next.

I've found that when I copy this in Terminal.app (select with the mouse and pressing Cmd-V), a newline character gets copied at the wrap point. This is no good.

I've also learned that if I open the file in vim and do the same, no newline character gets copied. This is great, but I don't particularly want to open vim every time I just want to look at a file quickly.

I have two questions:

  • Curiosity: What is the underlying reason one of these tools adds the newline and one doesn't? I can only assume it's a $TERM/termcap issue, but I really don't know.

  • Practicality: What are my options for a pager that won't insert newlines when I copy wrapped lines? Use vim as a pager? Change some TERM setting?

Thanks for any suggestions.

share|improve this question
    
P.S. you can use vim as a pager, just vim - or use the macros/less.sh script it comes with. see also vim.wikia.com/wiki/Using_vim_as_a_syntax-highlighting_pager – JasonWoof Oct 9 '15 at 19:12
up vote 1 down vote accepted

With Cygwin's less (version 444), I find that it only inserts newlines into lines scrolled in from the top of the screen when going back in a file, and that this can be avoided by forcing a repaint through pressing r.

share|improve this answer
    
I had been using less version 382. I updated to 444 and the newlines are gone! Thanks a lot. – nall Nov 10 '11 at 17:19

You must log in to answer this question.

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