Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Its been more than six months since I'm using stackexchange, so everyone out there knows that we're speechless about how much it has been helpful to us. But a small thing about the these sites that I'm in love with is that the way we can format our questions, I'm pointing particularly to the way we format code snippets, i.e. either keeping them in single quotes (I don't know if they're actually called quotes or something else) LikeThis.Code() or by prefixing four spaces.

I need to write most of my college work in Microsoft Word or OneNote, where I have large chunk of code to be placed, I like my writing organized, like everyone do, so I format those code snippets with mono fonts manually. But after coming to stack... sites, I was wondering if I can automate similar behaviour in Word through some third party program, like AutoHotkey or something else. While I know AutoHotkey deals a lot with keyboard, but I was looking for a more fast and efficient way to format block of words into mono fonts (its ok, I'm not expecting them to hightlight syntax). Before a few months, I read an article on HowToGeek about an application that automatically replaces short-forms of words that we often type to the full word, basically converting informal English to formal (I can't remember now what was that application). So with the same way, can I format text in mono fonts, using single quotes or something else? so that I don't have to manually select text and change fonts to mono.

share|improve this question
Single quotes are similar to apostrophes, and generally use the same key '. (Double quotes are, of course, ".) The term for the code-quote character you're looking for is "backtick" `. – CajunLuke Apr 1 '11 at 16:14
you may consider the below answer on Stackoverflow:… – Jaepetto Sep 3 '12 at 20:23
up vote 4 down vote accepted

Create a new style that formats the text the way you want. The style will likely need to include:

  • setting the font to a monospaced font like Courier New
  • setting the language to No Proofing (Word 2003 and older) or Do Not Check Spelling or Grammar (Word 2007 and newer)
  • setting the font size to something smaller; often code won't fit well on a page unless you make it smaller

To use this, select the text and change the style. All the formatting attributes will be applied at once.

Save the style in the template (the default) so that it's available in all documents.

If you need to do this often, you can assign a keyboard shortcut to the text so you don't have to select the style from the style menu. You don't need a separate program to do this. In Word 2007

  • Click the Office button.
  • Click the Word Options button (at the bottom of the menu)
  • Select Customize from the menu on the left.
  • Click the Keyboard Shortcuts: Customize button at the bottom.
  • In the Categories list, scroll down until you find Styles (second from the bottom) and select it.
  • In the Styles list, select the style you created.
  • Click in the Press New Shortcut key box.
  • Type the key combination you wish to use (e.g. Alt 1)
  • Click the Assign button
  • Click Close

When you close Word it may ask if you want to save the normal template. Answer Yes.

share|improve this answer
Works like a charm!!! Thanks a trillion....... :-) – Kushal Apr 2 '11 at 7:16

While the syntax differs from that of markdown, LaTeX offers a proper what-you-mean semantic markup environment for document preparation.

Of course, you'll have to give up your word-processing ways and join the light side.

share|improve this answer
I was about to post "Why do you HAVE to use Word? If you're in an academic discipline that's going to require that much code in papers, LaTeX should be standard!" – Shinrai Apr 1 '11 at 17:22

My impulse, personally, would be to create a hotkey to change the font formatting in a single keystroke, whether Word/OneNote can do that internally or having to use AutoHotkey.

I wonder if Word's AutoFormat can be manipulated to suit your needs? I don't have Word loaded on this box, or I'd go tinker with it myself.

share|improve this answer
Ok, that would be more helpful if I can select text and use hotkey to convert the fonts to the one I prefer (Droid Sans Mono, or anything), instead of opening the list and scroll through fonts. – Kushal Apr 1 '11 at 16:43

You must log in to answer this question.

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