I want to copy with mouse one line from one vim terminal to another vim terminal. This line is huge and has a hidden character (I presume at the beginning) that I do not want to copy.

In other words: I want to copy from the first character I consider good to the last character I consider good too. The problem is the copy with mouse does not go to the end of the line because this line is huge. It goes only to the end of the terminal.

The question is, how can I copy with mouse from character A to character B that is not visible on the terminal?

BTW these characters are a series of visible @. One per line on many lines. Using the arrow key there is only 2 lines with these @ in the middle. This shows between the first real line and the second real line.

  • Not sure i understand, but did you try triple click that will select the whole line. – Ruskes Dec 2 '14 at 7:38
  • Can I ask why don't you delete the @ you don't want. Just type :s/@//g and will be deleted. – jherran Dec 2 '14 at 10:22
  • @Buscar the triple click does not select the whole line. It is selecting only what is visible in the terminal. – Henri Revet Dec 2 '14 at 19:46
  • @jherran the @ are not editable/selectable characters. Actually I have understood what they are. It is a way for vim to show the line is too long to be totally displayed within the terminal window. I have experienced it with a smaller line; I can see them with a small terminal window. If I resize to a bigger window it disappears. Conclusion: the @ are not my problem. Something is screwed up with my file and I have no way to know what. Thanks anybody. I must close this thread. – Henri Revet Dec 2 '14 at 19:46

You can use a little trick: save that long line to a temp file and copy that.

  1. Select the desired portion of the line by moving the cursor to the first good position. By pressing v f [character], you select everything from that position to the next occurence of [character]. Pressing v $ would select to the end of that line. Use the power of Vim to select just the portion of the text you need.
  2. Write the selection to a temp file by typing :w /tmp/long_line.
    If the command already starts with :'<,'>, that's fine (it's a mark for your selection), just type ahead: :'<,'>w /tmp/long_line
  3. Exit Vim and process the /tmp/long_line file as you like. A simple solution would be cat /tmp/long_line and selecting the output

Alternative: Buy a larger screen ;)

  • this is the best solution... – Kevin Zhao Mar 20 '18 at 20:13

You must log in to answer this question.

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