rnso
rnso

Reputation: 24535

Copying all text to a new tab or buffer in vim

I have this function which get all text of current tab and does an echo on it.

function! Copy2new ()
   let alltext = getline(1,'$')  
   for s in alltext
      echo s
   endfor
endfunction

I know that :tabnew can create a new tab. How can I use above function to put entire text of one buffer to a new tab?

Upvotes: 2

Views: 65

Answers (1)

Jim U
Jim U

Reputation: 3366

Copies current buffer into a new buffer in a new tab

function! Copy2new()
   let alltext = getline(1,'$')  
   tabnew
   call setline('.', alltext)
endfunction

Upvotes: 2

Related Questions