Command to generate GUID ?

52 views
Skip to first unread message

Timothy Madden

unread,
Dec 1, 2008, 9:34:19 AM12/1/08
to vim...@googlegroups.com
Hello

I want to create my install packages with WiX in .wxs source files
edited with Vim.
For WiX I need to generate a new GUID for every new package I
distribute and every
major version of my program.

Could someone create a :command that would check the current selection or
the next 36 chararcters after the cursor to be hexadecimal digits
including minus
sign (anywhere in between) and then replace this text with the output
from a command
line executable (bin/GUIDGEN.exe) ?

Is there a script for this already ?

I do not know vim language, I am still learning the commands

Thank you,
Timothy Madden

Tony Mechelynck

unread,
Dec 1, 2008, 10:18:22 AM12/1/08
to vim...@googlegroups.com

Easy

:s/\%#[-[:xdigit:]]\{36}/\=`GUIDGEN`

Explanation:

:s substitute on current line
/ replace what?
\%# zero-width, current cursor position
[ start collection
- dash
[:xdigit:] (inside collection) hex digit
] end collection
\{36} repeat 36 times (i.e., multiply previous atom by 36)
/ replace by what?
\= expression
`GUIDGEN` the stdout of program GUIDGEN which is the PATH
(no flags) do it just once

See
:help :s
:help pattern.txt


Best regards,
Tony.
--
"If I am elected, the concrete barriers around the WHITE HOUSE will be
replaced by tasteful foam replicas of ANN MARGARET!"

Timothy Madden

unread,
Dec 1, 2008, 5:17:44 PM12/1/08
to vim_use
On Dec 1, 5:18 pm, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:
> On 01/12/08 15:34, Timothy Madden wrote:
[...]
> > Could someone create a :command that would check the current selection or
> > the next 36 chararcters after the cursor to be hexadecimal digits
> > including minus
> > sign (anywhere in between) and then replace this text with the output
> > from a command
> > line executable (bin/GUIDGEN.exe) ?
>
> > Is there a script for this already ?
>
> > I do not know vim language, I am still learning the commands
[...]
> Easy
>
>         :s/\%#[-[:xdigit:]]\{36}/\=`GUIDGEN`
>
> Explanation:
>
>         :s      substitute on current line
>         /       replace what?
>         \%#     zero-width, current cursor position
>         [       start collection
>         -       dash
>         [:xdigit:]      (inside collection) hex digit
>         ]       end collection
>         \{36}   repeat 36 times (i.e., multiply previous atom by 36)
>         /       replace by what?
>         \=      expression
>         `GUIDGEN`       the stdout of program GUIDGEN which is the PATH
>         (no flags)      do it just once


My vim says Invalid expression `wine GUIDGEN.exe` after I
type :Guidgen,
which I defined like this in ~/.vimrc:

command Guidgen :s$\%#[-[:xdigit:]]\{36}$\=`wine GUIDGEN.exe`

I have vim7.2 on Slackware.

I used $ instead of / in the search command because the path to
GUIDGEN
might someday contain a literal /.

I would also like to skip the first line of output
(reading Z:\home\adrian\GUIDGEN.exe) and then ignore the braces
around
the generated GUID, if possible

Thank you,
Timothy Madden

Jürgen Krämer

unread,
Dec 2, 2008, 2:52:41 AM12/2/08
to vim...@googlegroups.com

Hi,

Timothy Madden wrote:
>
> My vim says Invalid expression `wine GUIDGEN.exe` after I
> type :Guidgen,
> which I defined like this in ~/.vimrc:
>
> command Guidgen :s$\%#[-[:xdigit:]]\{36}$\=`wine GUIDGEN.exe`
>
> I have vim7.2 on Slackware.

you might try

command Guidgen :s$\%#[-[:xdigit:]]\{36}$\=system('GUIDGEN.exe')

instead.

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)

Reply all
Reply to author
Forward
0 new messages