Monday, August 27, 2012

Re: vim: how to substitute ^H into an delete action

Am 27.08.2012 15:53, schrieb ping:
> One question puzzles me for a long time and I'm not sure if it can be
> easily solved in vim...

Just ask ... there is a nice little trick you can use (works even better
than a :substitute), see below.

> say I have some log file, if I copy & paste into this email, it will
> look like this:
>
> PRVDRI-VFTTP-32:vol#show term len 50
> PRVDRI-VFTTP-32:vol#show subsc
> PRVDRI-VFTTP-32:vol#show subscribers
>
> actually in my vim terminal, it displays following literally
>
>
> 5057 ^MPRVDRI-VFTTP-32:vol#show ^H^H^H^H^H ^H^H^H^H^Hterm len 50
>
> 5058 ^MPRVDRI-VFTTP-32:vol#show subsc
> 5059 ^MPRVDRI-VFTTP-32:vol#show subscribers
>
> apparently someone input something wrong in his terminal emulator,
> delete them back with backspace, then input some new command into the
> text. so the logging program record all sequences without converting
> the ^H into "delete backward on charactor" action.
>
> is there a way to substitute, say all ^H , into an action that delete
> backward one charactor?
>
> b.t.w the ^H here is ONE special charactor, not ^ and H
>
> I have similiar issues for some other special charactors (^G, ^M, etc).

:h i_CTRL-R

:setl tw=0
:g/\b/exec "normal! 0\"rC\<C-R>r"

Control keys are processed as if typed in Vim, e.g. ^G expects another
character ... you should probably first remove unwanted chars.

--
Andy

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