DEUTSCH

@(#) Feb 22 2014, 20:33:14

This is the web page to the book

Reinhard Wobst, "vim ge-packt" (mitp Verlag Bonn 2004, ISBN 3-8266-1425-9)

about the vi successor vim, a very powerful editor running under a plenty of operating systems. Up to now, the book has appeared in German only (but it became already popular, the first edition was sold out after less than 1.5 years).

Here you find all shell and vim scripts from this book equipped with a hint to the web pages; dowload the zip archive:

zip archive (32 KB)

Moreover, you will find here all addendas and errata. I am always glad about feedback, and I will try to answer it as fast as possible (a response time can no more be guaranteed today, however). To protect your mail against being accidentally deleted as spam, it will helpful to choose a subject like "vim book" or similar.

My mail adress (which hopefully will remain valid for a long time):

r.wobst+@+gmx.+de

(the characters "+" are to be deleted, of course - the are meant to be a protection against spam robots).

Errata and Addenda of the 4th edition

The Python script gpgvi.py mentioned in 7.4.3 (p.320) was missing. You can find it in the new zip archive. Possible changes as well as documentation and security discussion can be found (together with other free software) under

https://bitbucket.org/ReinhardW

p.214:

Thanks to a hint from a friendly reader, the commands "normal" in the script mkfliess.vim should be followed by an exclamation mark "!" to avoid irritations because of key mappings. In the release 1.5 of the zip archive this is already done.

Errata and Addenda of the 3rd edition

p.269:

Of course, there must be ":highlight" and not ":hilight".

Errata and Addenda of the 2nd edition

p.74: In command "S", delete "von Cursorposition bis Zeilenende" ("S" does not substitute text from cursor position to line end but the whole line, it is a synonym to "cc")

Errata and Addenda of the 1st edition

p.14 (Preface)

Because of unknown reasons, I renamed my best corrector from Mario Lorenz (correct form) to Mario Lanze. Sorry, he was really very engaged an helpful ...

p.14 and 17: "Molenaar"

Of course, "Moolenaar" is correct.

Option "fileformat"

I should have mentioned an important option: 'fileformat', or shorter, 'ff'. It solves the problem of end-of-line characters differing between UNIX, DOS/Windows, and Mac. If each line of a file ends with '\n', the fileformat 'unix' is assumed; for '\r\n', 'dos' will be taken, and if only '\r' is found at the end of each line, 'mac'. If the fileformat differs from the default on your computer, it is shown in the baseline.

If you want to export a UNIX/Linux file to Windows-only-users, then type ":set ff=dos" before saving. Analogously you can convert DOS files to UNIX: "set ff=unix" (though this usually does not matter; only the Notepad users under Windows wonder why UNIX files appear as one long line).

read quoted printable text

Because of different reasons, some texts appear as "quoted printable" encoded. This is a special coding that can represent umlauts, among other things. For instance (a German example):

Im R=FCckblick wars eine sehr sch=F6ne =

Internally, many mails are encoded this way. Often enough, however, somebody cuts such texts by mouse and stores it somewhere else, and you wonder about the strange format. There are Microsoft mailers that even code HTML as quoted printable ... but HTML can do such coding itself! It is possible that your browser shows garbage or refuses to display the document.

The answer may be "vim and Python". Though there is a ready-to-use Python module 'quopri' that encodes and decodes, it cannot join lines in this context (the alternatives I got mailed all lacked this feature!).

So this was my first real case where I needed the Python interpreter which is optionally embedded in vim (maybe, you must translate vim yourself to this end, should there be no ready package for your system). The script is contained under the name "quoted_printable.vim" in the archive and can be stored under this name in $HOME/.vim/plugin/. It is astonishingly simple and shows the power of Python in list processing. Since the Python interpreter should not be loaded on each vim startup, I defined the local function pq() which loads the interpreter and the modules on demand.

Usage: Press F12 to activate the feature. Nothing happens (besides a message), the feature is initialized only. Then mark the quoted printable text visually (put cursor on begin, 'V', put cursor on end). Press F12 again, and you get human readable text. You can repeat the process "mark - press F12" as often as you want, and you also can save the converted blocks.

Decrypt GnuPG/PGP-Mails with pushing a button

The following may appear extremely conservative: The decryption of PGP/GnuPG enciphered mail is usually done by the mailer (kmail, mutt, enigma ...). In practice, however, there are endless problems. Some people send so-called inline-PGP, other PGP/MIME; kmail stores mails in encrypted form so that you cannot search them with other toos; when working remote in text mode you might have access to pine only ... there are many opportunities to be (negatively) surprised.

The simplest and only appearantly circumstantial solution is to store the mail as file first and decode it then. To this end, a simple "gpg filename " suffices. However, the file is renamed during this action, and you often stuck into some encoding like quoted_printable. An especially "nice" error message was "gpg: No valid OpenPGP data found" - and gpg sayed good-bye. After a long search it became clear that the sender's mailer appended a blank after "--- BEGIN PGP MESSAGE ---", and only newer versions of gpg can treat that. When this obstacle was overcome (and quoted_printable decoded), nasty "^M" characters appeared at line endiings - it was a DOS file.

At this moment, I disliked to do all manually, and I wrote a small plugin gpg.vim (that has to be stored in $HOME/.vim/plugin, as usual). It requires a small Python script quopriconv (which is almost identical with those described above). Put it into some bin-directory.

Usage:

Load the encrypted mail as file in the vim. After pressing F7, the pass phrase is requested, and the encrypted part will be replaced. The blank mentioned above is removed if necessary, and optional "^M"'s at the line endings will vanish. After this, sometimes you have to press ^L to remove gpg messages (which vim cannot see).

Some mails are UTF-8 encoded (i.e., unicode). In this case press F6 AFTER decryption (i.e. after pressing F7) - then unicode will be converted to ISO 8859-1. Users of SuSE Linux 9.1 and later will have the inverse problem since the work with unicode by default: They can change the one line in function uft() to

'a,'b !recode ISO-8859-1..UTF8

You will find this script in the archive. - Meanwhile, this script has made life much easier than all mailer plugins. I should cite the slogan:

Remember that the ark was built by an amateur;
the Titanic was built by professionals.

Translating vim

When vim is translated with gcc3.3, "features=big" and "-O3", the command "G" puts it in an endless loop for a certain file (but not when stepping forward with ^F). Obviously, this is a compiler error, but it is hardly to localize (the concerned source "syntax.c" is not so simple).

Workaround: If you translate with "features=big", give only the switch "-O2". With gcc2.95.3 (for instance, under SuSE 8.x) there are no problems.