Replace, insert n times a specific character

How can using Vim, replace one character with another repeating it 10 times?
Ex.:
Transforming this: 125A986
That: 125##########986

Deleted, did not read correctly the subject :X

Couple ways I can think of doing something like this. Search/replace all instances of 'A' with 'XXXXXXXXXX':

:%s/A/XXXXXXXXXX/g

or.. search for the character you want with '/A'. Once found (or before) map a key to perform the switch on the next character in your search:

:map v nxiXXXXXXXXXX^V[ESC]

I tend to use 'v' as my mapped key since it isn't used for anything else.

Peterro, I really use the command:%s/A/XXXXXXXXXX/g", however, I need a command that can be used in situations that have to repeat the character 10, 100, 1000, 10000 times. Understand?

Well, the best I've come up with is to:

:map v iX^[

where X is the character you want as the replacement. Now search for the character you want to replace and when you find it, press 'x' to remove that character and then type:

100v

This will insert 100 of the replacement characters. Hit 'n' to go to the next character to be replaced.

It's not really an ideal solution but it sort of gives you what you're looking for. I was unable to get a search '/' or character replacement 's' to work as a map to be performed multiple times. Maybe someone else has a better solution.

Thanks Peterro, solved my problem. I will continue looking for a script that solves this problem more generic.

Glad it worked, are you really looking for a script solution or one that is in vi/vim like your original post suggested?

Hi Peterro!
I'm beginner, and use gvim version for Windows and my english is also not very good.
I do not know if the original question was clear, but I need of a script to search a word and replace with one character repeated any number of times. Example: replace "txt" for "|" repeated about 500 times.
The proposed solution solves the problem, however it is not very flexible.

What scripting language would you be using and on what platform?

I use Windows XP SP3. As for language, is the own gvim.

Sorry, gvim is an app/editor and not a shell scripting language though you can do a lot with it. You may want to look into installing cygwin to get ksh or bash onto your box to have a scripting environment along with other tools such as sed/awk/grep etc. With something like that the scripting is fairly simple to do what you want. Once you get a scripting environment in place, some searches on this site should easily find examples of things similar to what you're trying to do.

Thanks for the help Peterro, I will study more about it.

echo enter the value of n
read n
char=X
while [ $n -le 0 ]
do
char=X$char
n=`expr $n - 1 `
done
sed -i 's/A/$char/g' your_file >> temp ; mv temp your_file