On Wed, Dec 12, 2012 at 3:27 AM, Ben Fritz <[email protected]> wrote:

> On Tuesday, December 11, 2012 6:55:30 PM UTC-6, JohnBeckett wrote:
> > Ben Fritz wrote:
> >
> > > ...
> >
> > > call setline(".",[line,repl1,repl2,repl3])
> >
> >
> >
> > There is a problem with that because four lines will be inserted
> >
> > into the buffer, and those lines will OVERWRITE existing lines.
> >
> > That's why my script used 'setline()' to replace the first line,
> >
> > and 'put' to insert the extra lines.
> >
>
> Oops, I guess I wanted append(). I thought I used setline() in TOhtml like
> this, but I only do it this way when the new buffer is empty. For adding
> text TOhtml uses append().
>
> --
> 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
>

Many thanks John and Ben for your help.  I'm not sure though how to use
nr2char() for the second change.  However, I slightly modified John's
convert() function and got the required result:

function! Conva_d(linenr)
  let line = getline(a:linenr)
  let result = []
  for i in ["a","b","c","d"]
    call add(result, substitute(line, 'x\(\w\)\@!','_' . i, 'g'))
  endfor
  call setline(a:linenr, result[0])
  execute a:linenr . 'put =result[1:]'
endfunction

-- 
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