Wikia

Vim Tips Wiki

Changes: Vim Tips Wiki:Code guidelines

Edit

Back to page

(Need "&lt;pre>" not "<pre>" when nested.)
(remove typo and add note about special characters in pre)
 
Line 6: Line 6:
 
A simple alternative is to insert a space before each line in the block, but that method can give the problems discussed below.
 
A simple alternative is to insert a space before each line in the block, but that method can give the problems discussed below.
   
If you want syntax coloring, you can use <code><nowiki><source lang="vim"></nowiki></code> ... <code><nowiki></source></nowiki></code> instead of 1<code><nowiki><pre></nowiki></code>.
+
If you want syntax coloring, you can use <code><nowiki><source lang="vim"></nowiki></code> ... <code><nowiki></source></nowiki></code> instead of <code><nowiki><pre></nowiki></code>.
   
 
We use both <code><nowiki><pre></nowiki></code> and <code><nowiki><source></nowiki></code> blocks, without any strong preferences either way. Use whichever suits your taste, but please remain consistent with the rest of a tip when editing an existing one.
 
We use both <code><nowiki><pre></nowiki></code> and <code><nowiki><source></nowiki></code> blocks, without any strong preferences either way. Use whichever suits your taste, but please remain consistent with the rest of a tip when editing an existing one.
Line 13: Line 13:
   
 
==Examples and explanations==
 
==Examples and explanations==
When you use <code><nowiki><pre></nowiki></code>''Some Text''<code><nowiki></pre></nowiki></code>:
+
When you use <code><nowiki><pre></nowiki></code>''Some Text''<code><nowiki></pre></nowiki></code> or <code><nowiki><source></nowiki></code>:
 
*''Some Text'' is not parsed for wiki code (it's as if you had used <code>&lt;nowiki&gt;</code>).
 
*''Some Text'' is not parsed for wiki code (it's as if you had used <code>&lt;nowiki&gt;</code>).
 
*''Some Text'' is taken as preformatted (so whitespace, including line breaks, is preserved).
 
*''Some Text'' is taken as preformatted (so whitespace, including line breaks, is preserved).
 
*''Some Text'' is displayed in a <code>fixed-width</code> font.
 
*''Some Text'' is displayed in a <code>fixed-width</code> font.
*Special characters (like <code>&amp;lt;</code> for <code>&lt;</code>) are processed normally.
+
*Special characters (like <code>&amp;lt;</code> for <code>&lt;</code>) are processed normally (but are usually not required, e.g. <code>getline("'<")</code> can be typed literally).
   
 
Simply prefixing each line with a space gives the same result as using the <code><nowiki><pre></nowiki></code> tag, except that in a line prefixed with a space, normal wiki processing rules apply (for example, <code><nowiki>''</nowiki></code> gives italics).
 
Simply prefixing each line with a space gives the same result as using the <code><nowiki><pre></nowiki></code> tag, except that in a line prefixed with a space, normal wiki processing rules apply (for example, <code><nowiki>''</nowiki></code> gives italics).

Latest revision as of 14:52, August 20, 2013

Around Wikia's network

Random Wiki