5

3

I often end up wanting to include snippets of code when editing a case, wiki article, or Kiln code review.

Is there any way for me to embed syntax-highlighted code snippets in FogBugz/Kiln?

flag

1 Answer

8

That's what the new Code Snippets plugin is for!

Note: This plugin is only available for FogBugz 8.

If you're using FogBugz On Demand, you can install this plugin by navigating to

https://[youraccount].fogbugz.com/default.asp?pg=pgHostedPluginsInstall

and enabling the "Code Snippets" plugin. Once you've installed the Code Snippets plugin you'll be able to embed code snippets into your bug events, wiki articles, and Kiln code reviews (if you have Kiln installed), as follows:

When editing a case

Just wrap your code snippet in [code][/code] OR <code></code> tags and you're all set!

For example, if you include the following along with the rest of your edit message:

[code]
var CodeSnippetsEnabled = true;
[/code]

You'll end up with the following after you submit your changes:

Bug Event Code Snippet

Inline code snippets

If you want to include small, single-line code snippets in the middle of a sentence, just keep your code snippet to a single line, and the Code Snippets plugin will display your snippet inline.

For example, if you include the following:

You should use <code>var fCodeSnippetsEnabled = true;</code> instead.

You'll end up with the following after you submit your changes:

Inline code snippet example

When editing a wiki article

  1. Select "Code Snippet..." from the Insert menu...

    alt text

  2. Enter your code in the resulting dialog...

    alt text

  3. Select your options for horizontal scrollbars and line numbers, and then click OK.

When editing a code review in Kiln

Just use the exact same [code][/code] or <code></code> tags as you would when editing a case in FogBugz and you should be all set!

Note: This feature requires Kiln v2.2 or later (as well as the Code Snippets plugin, of course!)

Triple-word-score bonus! (a snippet for your code snippets)

"Man, I loves me some code snippets," I hear you say, "but gosh darn it's cumbersome to keep typing [code]...[/code]. Can't you help a player out?"

Yes we can! Just use FogBugz' super-easy "Snippets" feature (My Settings -> Snippets) to create a code` snippet that expands to the following:

<code>[[codez]]</code>

...and you'll love code snippets even more! Just start editing your case, type code`, and FogBugz will automatically highlight the [[codez]] section for you so that you can just start typing (or pasting) in your codez! YAY!

What about other types of formatting or pre-formatted text?

The Code Snippets plugin only aims to support embedding syntax-highlighted code snippets, but in a pinch you can also use it for embedding other large, pre-formatted blobs of text (e.g., stack traces, SQL query results, etc.):

Using code snippets with other pre-formatted text

link|flag
3 
That's great, db. Any chance we'll see some of the other markdown available in stackexchange (strong, emphasis, hyperlink, blockquote, inline image, numbered list, bulleted list, heading, horizontal rule) for FB cases too? – Ken Morse Aug 19 2010 at 17:03
@Ken: Baby steps... :) – Rich Armstrong Aug 20 2010 at 12:19

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.