On Dec 6, 3:13 pm, Gary Johnson <[email protected]> wrote: > I've been looking at logs of telnet sessions to a target system with > a shell that uses more-like paging of command output. When the more > prompt appears and the user hits the space bar, the shell erases the > prompt with a series of backspaces and displays the next page of > output. Consequently, the log is full of lines like this: > > [more 50%] (q,g,space,enter) > ^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^HNext line of output > > To make the log files easier to read, I wrote a function that > deletes all occurrences of a non-backspace character followed by a > backspace in the current line. > > function! Col() > while 1 > try > s/[^[:backspace:]][[:backspace:]]//g > catch /E486:/ > break > catch /.*/ > echo v:exception > break > endtry > endwhile > endfunction > command! Col call Col() > > This works fine as long as I execute it manually for every line I > want to clean up. To clean up the whole file, I tried this: > > :g/^\[more /Col > > When executed on a real log file, the command "never" returns and my > CPU usage goes to 100%. Ctrl-C doesn't even work. > > On a short test file with 9 lines of text, one of which begins > "[more " and contains 28 backspaces, > > :g/^\[more /Col > > doesn't terminate until I hit Cntl-C. At that point, the file has > been correctly modified but ":messages" shows > > 28 substitutions on 28 lines > > What's going on and how do I fix this? > > I'm running Vim 7.3.364 on a Fedora 11 system. > > I know I could solve this particular problem with something like > this: > > :%s/^.*[[:backspace:]]// > > but I'm looking for a more general solution that also fixes lines > where the user has backspaced over a mistake. > > Regards, > Gary
This seems to work: nmap <F5> :%s/[^\b]\b//ge<cr> -Bill -- 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
