In a script when one calls "cursor(line, column)" or
"execute normal 4rx", implicitly it is the current buffer
that is the target; it is the current buffer that is changed.
I'd like to know if its possible to explicitly alter the
target buffer in scripts such that, optionally, the same
edit commands can be applied to either the default buffer
or to some other, possibly hidden buffer.

function doSomeEdits()
  if g:writeToHiddenBuffer
    " save current buffer
    " make hidden buffer the target
  endif

  try

    call cursor(someLine, someColumn)
    execute "normal 4rX"
    call cursor(someLine, someColumn+4)
    execute "normal iyyyy"
    let line = getline('.')
    return len(line)

  finally
    if g:writeToHiddenBuffer
      " restore current buffer
    endif
  endtry

endfuncion

Here, either the current, normal buffer is altered or, if
g:writeToHiddenBuffer is true, then some other buffer
is changed, but the exact same editiing commands are used.
So, is it possible?

Thanks.

Richard
--
Quis custodiet ipsos custodes

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to