Helloo!

I have a .txt file with around 1000 lines in it - each line just has a number. What I want to do is to copy all 1000 lines and paste it into an excel sheet.

So, I went up to the first line, changed to visual mode, and used shift+g to select all lines. Then I used ctrl+insert to copy them and then I went to excel and pasted them - but, only 41 lines get pasted!! :(

Please help!!

Dani AI

Generated

This is a terminal/clipboard mismatch rather than a hardware limit. As guessed, the copy you invoked ended up using the terminal's visible-screen selection (the 41 lines you saw) instead of Vim's internal buffer, so only the viewport was placed on the Windows clipboard. 's "try other programs" check was useful — it rules out a system memory limit.

Practical ways to move the whole file into the OS clipboard (pick the one that fits your setup):

  • If your Vim has clipboard support, yank the entire buffer into the system clipboard register from within Vim.
  • From a shell on the same machine you can pipe the file into the platform clipboard utility (examples shown below):
:%y+
xclip -selection clipboard < file.txt
xsel --clipboard --input < file.txt
pbcopy < file.txt
type file.txt | clip
Get-Content file.txt | Set-Clipboard

Notes and troubleshooting:

  • Check whether Vim was built with clipboard support before relying on the in-editor register (use vim --version or :version and look for +clipboard or +xterm_clipboard).
  • If you're SSHing into a remote host, clipboard commands act on the remote side; copy the file to your local machine first or use an SSH-aware method to transfer it.
  • If you are running inside tmux/screen, they may intercept selection; use their copy/paste integration or the shell-based clipboard commands above.
  • If pasting into Excel, prefer Excel's "Import from Text/CSV" or format the destination column as Text first to avoid numeric/date coercion.

Following those steps will reliably get all 1,000 lines into Excel instead of only the visible screen.

Recommended Answers

All 4 Replies

have you tried other programs?

my guess would be you are hitting a limit, it may be software or hardware. obviously if it is a limit in your hardware (memory), there is not much you can do, unless you can get it onto another computer.

Hmm... no, I don't think that's it. My lappy's brand new, and it's almost empty right now... Besides, 41 lines seems too much of a coincidence. That's exactly how many lines I see on the screen at a time. Also, I can copy 1000 lines of text from excel to other docs easily enough...

This is a limitation by "What's on the screen", if you want to use the vi copy function you could do something like '1000y' to put it into the yp keyboard.

If you want to do this easier, you can use gvim, select all, then use the copy button on the toolbar, which should get rid of the per screen limitation, or you can just rename the file to .csv and open it in excel, it will automatically put all the values on the first column.

Okay, thanks!!! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.