What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 134 Stack Exchange communities.

I was trying to explain a part of a code through chat, and I noticed that there was no way to post code blocks in the chat interface. Although I agree that large codes are rarely posted in the chat interface, but I think we should have a feature to post code blocks in chat, especially since stackoverflow encourages long discussions in the comments to be continued in chat. In such cases code blocks can be necessary.

share|improve this question

1 Answer 1

up vote 10 down vote accepted

The feature is already there. Just preface each line with 4 spaces, like you would on the site.

If you don't want to do this manually, press the fixed font button (which only appears when you are entering more than one line of text) or use Ctrl+K (the same shortcut as the sites' editor):

chat entry box showing the "fixed font" button highlighted

And if you're not copy/pasting code in, remember you can use Shift+Enter to add a line break instead of sending the message, and then you just either add 4 spaces as you go along or use the button/shortcut at the end.

share|improve this answer
    
I'm not sure what happened with this, but I don't see any "fixed font" button in chat, and if I prefix with 4 spaces, the code does not appear in a fixed font. Was the feature disabled? –  Jez Nov 11 '12 at 19:25
    
Just had a quick test in the sandbox (see here) and the 'fixed font' button still appears to me if I have something multi-line in the chat box. The resulting message does appear to be monospaced, as expected, after using the button or manually prefixing a line with four spaces. Ins short: it's currently working for me as expected. –  DMA57361 Nov 11 '12 at 19:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .