Saturday, August 2, 2014

RE: vim function for printing text in to a buffer.

sinbad wrote:
> i'm trying to write a vim function to generate the following
> output. first of all why is it so difficult to ptint text into
> the buffer, i thought vim will have a simple printf() command
> which can dump the text into the buffer, but after googling a
> lot i found that append() is the function i should use. so i
> wrote the following function.
> ...

I cannot work out exactly what you want, but a quick translation
of the code you posted would be the following.

function! Test()
for a in range(20)
for b in range(20)
$put =printf('1.2.%x:%d', a, b)
endfor
endfor
endfunction
call Test()

The '$put' appends to the current buffer ($ = last line) the
value of the expression ('='). The printf generates a string
containing '1.2.', then a in hex, then ':', then b in decimal.

John


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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment