2

I would like to create a new scratch buffer in vim script. I would like to use this buffer to output the result of the execution of a scala script.

I am creating the buffer with this function:

function! ScratchBuffer()
  vnew
  setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile
endfunction 

then I call it as follows:

let outputBuf = ScratchBuffer()

outputbuf should contain the buffer number. However, this doesn't seem to work. I need the buffer number in order to then use the buffer in a python script.

5

Your function returns nothing, but you call it expecting the buffer number. This should work:

function! ScratchBuffer()
  vnew
  setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile
  return bufnr('%')
endfunction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.