Re: [SLUG] how to make vim DTRT

From: Dylan William Hardison (dylan@hardison.net)
Date: Thu Mar 13 2008 - 14:14:49 EST


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

However, you could use vim's (ex's) builtin s///, like so:

:%s/\240/ /g

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?

-- 
Keep grandma off the streets -- legalize bingo.
-
GPG Fingerprint: 412C CCE9 DDA2 4FE9 C34F  754B 0863 0EA6 712E BBE1
-----------------------------------------------------------------------
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:24:09 EDT