Fandom

Programmer's Wiki

Sample code in a wiki

407pages on
this wiki
Add New Page
Talk3 Share
16px-Pencil

To put code in one of these cute boxes, you have to indent each line of wiki-text by one space:

 def function():
     print "hello"

Fortunately, cutting and pasting out of the cute box results in properly formatted Python code. To quickly format your code for cut-and-paste into the wiki on a Linux computer, you can use the sed command.

 $ sed -e 's/^/ /' < file.py

This command adds a single space to the beginning of each line of your file. Since empty lines cause new boxes to be created, you'll probably want to adjust the output code to taste.

Easier Editing ExternallyEdit

For even easier editing, you can use an external (read: sane) text editor. There are apparently [lots of ways]. I did the [ee.pl] method, and it worked.

In vim, you can add a line to your vimrc that will add one space to any block of text that you highlight, if you press backslash-p.

:map <leader>p :!sed -e 's/^/ /'<CR>

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.