On Thu, Jan 1, 2009 at 11:49 PM, James G. Sack (jim) <[email protected]> wrote:
> James G. Sack (jim) wrote:
>> Carl Lowenstein wrote:
>>> Is there some way to make VIM display non-ASCII characters as
>>> something distinguishable. Like octal or hex or even the way that
>>> "cat -v" does?
>>>
>>> I know, ":1G!Gcat -v"
>>>
>>> But a reversible way, similar to "set list", "set nolist" would be
>>> nice. I have not found it in some reading of Steve Oualline's _Vi
>>> IMproved_ book.
>>>
>>> The use for this is cleaning up text files that were created by
>>> programs that insert non-ASCII characters for apostrophes and quotes
>>> etc.
>>>
>>
>> google on
>> vim hex mode
>> gives some good hits. First things I saw:
>>
>> set display=uhex
>> also, in command mode
>> ga
>> will give info about the character at the cursor position.
>>
>> It seems like there ought to be a way to give pure hex rather than hex
>> mixed with unicode that I get in uhex. ??
>
> there is also a prog called bvi that looks more like a conventional hex
> editor
> http://bvi.sourceforge.net/
1) vim -b and "set display=uhex" do not seem to be implemented in the
version of VIM I am using. It came with CentOS 5.2.
[...@delta ~]$ vim -h
VIM - Vi IMproved 7.0 (2006 May 7, compiled Nov 25 2008 11:43:45)
2) piping the VIM buffer through xxd(1) as found in a Google search
does indeed give a hex display of the whole text, and it is supposed
to be reversible. But it isn't very easy to read, let alone edit.
3) apropos hex | grep edit comes up with "ghex" which is a GUI hex
editor. It seems to be usable, at least for small changes.
Characters are displayed as 2-digit hex in one pane of the window and
ASCII on the same line in another pane. Non-ASCII characters are
displayed as dots. Moving the cursor in one half of the display moves
a ghost cursor to the corresponding place in the other half. You can
delete the dots and replace them with other characters, and the empty
space is closed up. By the way, to invoke ghex from the command line,
its name is "/usr/bin/ghex2".
The particular bunch of text I was working with has a 3-byte
representation for an apostrophe, E2 80 99. determined by using "od -t
x1". VIM displays this only as an apostrophe-like symbol, in one
character cell. Moving the cursor to that place and entering "ga"
gives the result "hex 2019". Which is not right at all.
I have not found a hex dump routine that produces as user-friendly a
display as "od -cb" does for octal. That is, parallel lines of
character and numeric representations of each byte, with the same
horizontal spacing so it is obvious what belongs together.
Here is a uuencoded representation of a small text file, which is
supposed to say "Luigi's Pizza".
- - - - - - -
begin 664 luigi.txt
03'5I9VGB@)ES(%!I>GIA"@``
`
end
- - - - - - -
Side note. uuencode/uudecode seem to have disappeared from modern
Linux systems. Their replacement is called uuenview/uudeview, and is
almost but not exactly compatible. Notice the lack of the second
space after "begin". I don't know what this might do with a real
uudecode.
carl
--
carl lowenstein marine physical lab u.c. san diego
[email protected]
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-newbie