Saturday, August 2, 2014

vim function for printing text in to a buffer.

hi,

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.

1.2.3.4
1.2.4.5
1.2.5.6
1.2.6.7
1.2.7.8
1.2.8.9
1.2.8.11

1. how do i print the numbers in hex, even though i used '%x'
it doesn seem to be working.

2. why the output is displayed in reverse order , i was expecting
1.2.1.1 to come first.

3. and even though i set the 'setf vim' whey doesn't vim
recognize that this is vim script and indent it properly.

func! Test()
let ma=0x1
let mb=0x1

while ma<20
while mb<20
call append(line('.'), "1.2.".printf("%x", ma).":".mb)
let mb+=1
endwhile
let ma+=1
endwhile
endfunc


actual output of above function:

1.2.1.19
1.2.1.18
1.2.1.17
1.2.1.16
1.2.1.15
1.2.1.14
1.2.1.13
1.2.1.12
1.2.1.11
1.2.1.10
1.2.1.9
1.2.1.8
1.2.1.7
1.2.1.6
1.2.1.5
1.2.1.4
1.2.1.3
1.2.1.2
1.2.1.1

-sinbad

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