Ipkiss/Restoring part of an original tip

Contents

To restore parts of the text from the original tips on vim.org, the idea is the following:

make a visual selection of some text (in a wiki tip)

transform this text into a clever regular expression matching the same text, but in the same format as it is in the vim.org original tip (this involves escaping some characters, replacing newlines with <br>, etc...)

find in the vim.org tip the text matching the clever regexp

transform this text back into what the wiki expects

replace the visual selection with the transformed text

This is very safe, because the regular expression is extremely precise, we cannot get bad matches (or more precisely, we can, but these matches would then be identical to the good match, modulo some whitespace/end of line).

For more efficiency of the script, I provide a ready-to-use package with all the tips from vim.org, to which I applied some post-processing, detailed at the bottom of this page. In particular I have removed all the embedded \r characters (see Using vim to edit tips to understand why they are problematic).

If you get the message "Could not find tip number", make sure that you have set the g:vim_tips_dir variable properly... and that you are really editing a tip migrated from vim.org!

If you get the message "Pattern not found in the tip from vim.org, sorry":

Make sure you did the visual selection as described in the Usage section above

Try with a smaller selection first (use gv to reselect the previous selection, and o to go from one side of the selection to the other one)

If there was no error, but the indentation is still bad, it's probably that the original tip on vim.org had a bad indentation already. Too bad... At least you may have fixed line spacing issues :)

You may get an extra empty line before or after the part of the text you restored. I am not sure whether it is a bug in the script or the effect described in :help v_p. I probably won't bother fixing this issue.

The script has been well tested, but if you detect a bug notify me and I will try to fix it.