Sunday, April 22, 2012

questions about submatch()

Hello to all readers,

I use submatch() to increment/decrement numbers in a text.

My questions are:
1) In my country the "comma" is seen as decimal separator.
submatch() doesn't seem to recognize the comma but use the "dot"
as separator.
Is there a way to let submatch() know that the decimal separator in the
text is the comma?
2) Often the numbers in my text have thousand separators.
submatch() doesn't recognize them.
%s/1.000.000/\=submatch(0) + 10/g gives as output 11
How can I tell submatch that dots are thousand separators?
3) In my text I have integers and float values.
If I use %s/"a search string"/\=string2float(submatch(0)) [+-]nr/g all
non float values have ".0" after the conversion.
If I use %s/"a search string"/\=submatch(0) [+-]nr/g there are no decimals
added after the conversion when there are float values.
How can I let submatch() know that it has to make a float value when
the increment/decrement value or the number self is a float, else it has
to see the value as integer?

Tnx,
Rameo

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

No comments:

Post a Comment