In a vim buffer if I have a list of characters say:

A

B

c

C

d

D

and for each one I want to replace it with its corresponding ascii code ( in decimal ). Is there a way to do this without using an external tool through :r!some_tool

For instance, I know there is the :ascii and ga commands but they print the value to the screen but I can't find a way to get its output into the buffer.

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

Check out str2numchar.vim. Down load & install in your vim plugins folder. Add the example visual mode key map to your .vimrc file:

vmap <silent> sn :Str2NumChar<CR>

In vim, highlight the text you want to convert and type sn.

link|improve this answer
Very close to what I want... And I could it could work for me with a little of extra search and replace afterwards. However, I think I like the answer posted on stackoverflow more because it doesn't use a plugin and is pretty much everything I needed: stackoverflow.com/questions/1834114/… Thanks for the advice though... – Neg_EV Dec 2 '09 at 17:50
I do like the visual nature of this solution though... – Neg_EV Dec 2 '09 at 17:51
No worries. If you can remember how to invoke that funtion inside a search clause like that, then you're my hero ;-) – DaveParillo Dec 2 '09 at 19:31
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.