NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: stupid question on vi



RVP <rvp%SDF.ORG@localhost> wrote:

> On Sat, 22 Feb 2025, Dave Tyson wrote:
>
> > I have a file which has some hex characters 0x80 and higher.
> >
> > I am trying to search for them so I can replace them. I can see them
> > and they appear, for example, like \x93 on the screen and occupy a
> > single character.
> >
>
> nvi(1) has a poorly-documented Ctrl-X key which can be used to both enter and
> search for (after a fashion) arbitrary chars. To input, let's say, \x93, do:

I'm not seeing the Ctrl-X thing on NetBSD 9.3, though maybe that's
the poorly documented aspect..

The OP should be able to use named buffers for this task.

Steps:
1) create lines with the commands you want to run:
  /\x93        # vi cmd: find/search forward in file for "\x93"
  :%s/\x93//g  # ex cmd: globally replace all instances of "\x93" w/ ""
  
2) move to each line and yank into a separate named buffer:
  "fyy  # => sticks '/\x93' into buffer 'f' 
  "gyy  # => sticks ':%s/\x93//' into buffer 'g' (global replace)
  
3) execute buffers as needed:
  @f    # => runs buffer 'f' ; use '/' and/or 'N' to repeat, 'x' to delete
  @g    # => runs buffer 'g' ; one-shot global substitution


IIRC there are also auto-generated buffers 1-9 that can also be
referenced; the ':display b' will show the contents of all buffers.

-B


Home | Main Index | Thread Index | Old Index