Edit: Added ideas from comments at the end of the blog
Not exactly a SQL topic, but I am working on formatting a chapter from a book I am working on with a cowriter and I realized that there were a few things that I find myself doing over and over with Word that I wanted to share. All of the tips are useful for formatting SQL in your blog posts, at the very least.
1. Shift – F3 – Applying this to a word/highlighted text in your document will cycle through the different states of capitalization. For example, if you have:
Fred is a crazy dude.
Highlight it and press Shift-F3:
THIS IS A COOL FEATURE
this is a cool feature
This Is A Cool Feature
If you are like me, you code everything originally in lowercase, but editors almost exclusively like the way caps look, so I find myself constantly setting keywords to caps using this feature. I learned this in a few sessions with Microsoft Learning where the person proctoring the session was using it on the screen. Saved me hours on the last book (you heard me, hours. I probably spent over 1000 hours writing and it might have been 2000. The book was 680 or so pages with lots of T-SQL.)
2. Get the application puretext from http://www.stevemiller.net/puretext/. This handy application will clear all formatting from text you have stored in your clipboard. Nearly every publisher has a style sheet that they require you use, and frankly if you have any Word skill at all you always use styles for titles and headings at the very least. The most annoying thing though is that the text you copy from SSMS has formatting in it, so when you paste it into your documents you have this formatting that you need to get rid of in lieu of the stuff that the publisher wants. With Puretext you simply use a slightly different paste key (like Windows-V) and you get the plain text you need. Same time estimate for this feature. Before I found this application I used to paste into Notepad, the copy it to the clipboard and then into Word. Very tedious.
3. Hotkeys on styles – As mentioned in 2, nearly every publisher has a style sheet that they require you use, and frankly if you have any Word skill at all you always use styles for titles and headings at the very least. Applying “heading 1” three or four times is no big deal, but applying code in text 1000 times in a 80 page chapter is not quite a much fun.
So, if you open up word, and find the styles ribbon (this is Word 2007, you can do much the same stuff in earlier versions, but I won’t demonstrate). Clicking the little arrow under the Change Styles button opens up the styles bar:
Now you can right click on any of the styles, choose modify to get the following:
Click on Format and choose Shortcut Key:
Once you choose a key (for the Code [ST] style I chose Alt-C. Now I highlight the term I want to make look like code and press Alt-C. Saves tons of time.
Note: A few commenters have noted that there is a way to make this work without PureText using Word functionality (I will demonstrate the Word 2007 methods. There are two ways:
First, when you paste text into Word 2007, you get a little menu at the end of your paste:
Click that and it will say:
Keep Source Formatting
Match Destination Formatting
Keep Text Only
Set Default Paste
This would be a clumsy way to keep text many many times, but it is nice for the occasional use. More interesting is the Match Destination. A lot of times I use text formatting to strip away some text formatting so I can reformat it.
The second is to set the default paste method. Opening up the Word Options menu from the Office Menu you see:
You can set it to behave using any of the three methods mentioned by default for several scenarios, the most interesting “Pasting from other programs.” If you didn’t want to set up something like PureText, and you only used Word (I am using LiveWriter right now, and I like pasting text into here for code, but not from blogs and documents) then that would be a very viable plan too.
What it just goes to show you is that all of the Office products are freaking massive. After writing 3000 pages or so using word through the years, I consider myself an above average user, but in reality, in comparison to what features are in there, I am a novice. These are just a few tricks I have learned, the first two from others (the second was from a newsgroup posting by the author, who’s website you will find the tool), the third something I started doing on my own (didn’t come up with the idea, just found it.) If you have other ideas, please share them here, on your blog, at conferences, etc. Writing is a chore to start with, but formatting is a nightmare if you don’t know the tricks of the trade.