I want some Vim script to remove percent encoding (where '%'
followed by two hex digits means the single character with the
given hex ASCII code, for example '%412' is 'A2').

It's easy to do this using :substitute with:

:s/%\(\x\x\)/\=nr2char('0x'.submatch(1))/g

However, submatch() does not work in substitute(), and
'\1' cannot be passed to a function (I think).

I would like either of the following to show 'abcAdef':

:echo substitute('abc%41def', '%\(\x\x\)', nr2char('0x'.submatch(1)), 'g')

:echo substitute('abc%41def', '%\(\x\x\)', nr2char('0x\1'), 'g')

But submatch() and \1 do not work here.

How can a submatch be used in an expression in substitute()?

John

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

Reply via email to