I’ve written loads of material from design documentation to white papers to proposals. Now I’m working on a book. I’ve come up with several writing tricks which work well for me when dealing with code-related issues.
One trick is to use GVim to quickly get rid of indents on code snippets I’m going to be pasting in to O’Reilly’s template. Sure, CopyAsHTML will get rid of indents if you so configure it, but using that results in fugly text. For example, the following text in VS:
// obtain stock information from xml file
DataSet ds = new DataSet();
System.IO.Stream file =
Assembly.GetExecutingAssembly().GetManifestResourceStream( "NPlotDemo.resources.asx_jbh.xml" );
ds.ReadXml( file, System.Data.XmlReadMode.ReadSchema );
DataTable dt = ds.Tables;
becomes this nasty stuff:
Instead I copy the snippet from VS, pop open GVim via SlickRun, paste the contents in, and with Shift-V (visual line mode), Shift-G (select to bottom), < (shift left), and after two periods (repeat last command) I’ve got all the indents out. gg takes me back to the top of the file, then Shift-V, Shift-G and Ctrl-Insert to copy the entire buffer content.
OK, that may look like a bunch of keystrokes, but it actually goes pretty easy. Plus it uses GVim/Vim which is the ultimate in lightweight text editors. As a matter of fact, I could make a Vim macro to do all that in one swell foop… I’ll knock that out soon. (Yes, yes, Notepad2 rocks. GVim rulz.)
Second trick relates to making screenshots of multiple windows. Alt-PrtScn nicely grabs the active window, eliminating background cruft. But what to do when you’ve got several windows at once you need to grab and you don’t want a bunch of confusing junk in the spaces between the windows? Easy: maximize an Explorer window opened to an empty (or lightly filled) and use that as your background.
I’d love to hear of any tricks you folks have come up with for authoring any sort of material, or pointers to good references for these sorts of tips.