Re: [SLUG] how to make vim DTRT

From: Eben King (
Date: Sat Mar 15 2008 - 14:32:26 EST

On Thu, 13 Mar 2008, Dylan William Hardison wrote:

> Spake Eben King on Monday, March 17, 2008 at 04:41PM -0500:
>> Something -- I think Google Groups -- is replacing the second space after
>> a sentence as well as the final space in a time (between H:MM and [ap]m)
>> with 0xa0 = 0240 which is presumably a non-breakable space in some
>> encoding. I'd like to replace these with everyday spaces. I've got a
>> "tr" command that does it ("| tr '\240' ' '") but what I don't know is
>> how to make vim pipe the whole document through that, and replace all
>> text with what comes out.
>> :%something|tr '\240' ' '
> Very close. '%' is the range for the entire file, and you just need the ex
> command to pipe something to an external program.
> That command is '!', so you have:
> :%!tr '\240' ' '

Thanks, works great.

> However, you could use vim's (ex's) builtin s///, like so:
> :%s/\240/ /g

vim says:

| E65: Illegal back reference
| E476: Invalid command
| Hit ENTER or type command to continue

Try again?

> Also, if you want to pipe a subset of a file through tr (or vim's builtn s///),
> you can enter visual mode (with "v"), select lines using the arrow keys,
> and type ':!tr a-z A-Z'. The selected portion of the text will be piped through
> 'tr'. Nifty, eh?

Note to those playing along at home: leave the "'<,'>" it insert after the
colon. Otherwise it'll just change the first line. Baby steps on the path
to vi guru-hood. Thanks.

-eben      QebWenE01R@vTerYizUonI.nOetP
VIRGO:  All Virgos are extremely friendly and intelligent - except
for you.  Expect a big surprise today when you wind up with your
head impaled upon a stick. -- Weird Al, _Your Horoscope for Today_
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS).  Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.

This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 15:25:30 EDT