On Jan 10, 6:44 pm, "John Beckett" <[email protected]> wrote:
> Sean wrote:
> > let readonly_list = ['0000 AAAA', '0010 BBBB']
> > let readonly_pat = "^" . 0010
>
> But the 0010 is parsed as a NUMBER and the result is appended to "^".
>
> In Vim, the following will display 8:
> :echo 010
>
> because (according to the infallible law of the C language), a number
> beginning with a zero digit is octal.
>
> Where did the 0010 come from? Is it in a variable (with value decimal
> 10)? Any you want it put into a four-digit string with leading zeroes?
> If so, try (untested):
>
> let readonly_pat = '^' . printf('%04d', myvariable)
>
> John
That is genius!
let myvariable = 0010
printf('%04d',myvariable)='0008'
printf('%04o',myvariable)='0010'
The last is what I really want!
The data are from a data file like:
0000 AAAA
0000 AAAB
0010 BBBB
The number is <key>, the <value> is multi-byte, and it is one to many
mapping.
BTW, there are hundreds, if not thousands, of 'invention' to do such
kind of mapping.
This is for vimim.vim plugin.
Thanks for your inspiration!
Sean
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---