Monday, August 27, 2012

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

On Monday, August 27, 2012 8:53:51 AM UTC-5, ping wrote:
> One question puzzles me for a long time and I'm not sure if it can be
>
> easily solved in vim...
>
>
>
> 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).

I had to do this with ^H once, I think I solved it with something like:

:g/^H/while getline('.') =~ '[^^H]^H' | s/[^^H]^H//g | endwhile

There are probably better ways to do it.

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