History
Forum Edit this page Discussion

Forum:Respect the original indentation

From Vim Tips Wiki

Jump to: navigation, search
Forums: Index > Help desk > Respect the original indentation


Several tips (such as VimTip931, before manual fixing) contain indented code. The migration script always loses the indentation.

Would it be possible to detect (not empty) lines starting with whitespace, and preserve the indent of these lines? In addition, it would be great not to have the extra carriage return for such lines, because a line of code is not supposed to have its own paragraph. Of course, the icing on the cake would be to put the whole block of code inside <pre></pre>...

It may be too late now that the migration is done, but it would at least be interesting for all the vimtips never edited manually.

Ipkiss 11:23, 21 July 2007 (UTC)


I haven't got around to thinking about this issue, although like you, I've certainly wondered about it. In principle, you could write a client-side bot - a program running on your workstation. The program logs on to the wiki, gets a page, and manipulates the wikitext, then saves the result.

I have a feeling that the variability of the tips makes such a bot most unlikely to be successful.

I was thinking that some funky key mappings or scripts in Vim could help. You would manually edit a page, then copy the wikitext to Vim and munge it (I do this when changing a significant amount of stuff, but I haven't got any clever features).

When the Vim mailing lists come back to normal in a week or two, it might be worth asking there for ideas. If I remember, I will do that.

-JohnBeckett 02:11, 22 July 2007 (UTC)


Since the indentation has been lost during the migration, it is not very convenient for a bot to restore it, because it has to go to the original tip page to get the code with its original indent. That's why I was more thinking about a re-import of the untouched pages, with a more clever import script.

But the bot idea is also appealing, I might give it a try if I find enough information about bot creation. It is more interesting than doing all the changes manually!

Ipkiss 09:54, 22 July 2007 (UTC)


A few precisions:

  • the indentation on vim.org tips is done using &nbsp;
  • the "extra carriage return" I was talking about in my first post is due to \r characters directly inside the tip (just before <br>), probably coming from people editing tips on Windows. So the \r characters should be ignored, instead of becoming additional end of lines.

Ipkiss 14:14, 22 July 2007 (UTC)

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Pushing Daisies
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Godzilla
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Respect the original indentation"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation


.