Markdown Creative Writing in Visual Studio
Contents
- Why on earth would I ever consider writing in Microsoft Visual Studio?
- If I use it what's the benefit?
- How can I improve my workflow?
- The result
Why on earth would I ever consider writing in Microsoft Visual Studio?
For the general writer
There's probably no convincing reason why you should.
For software developers who use it anyway
- You already have it installed
- You know how it works
- You're familiar with the keystrokes and the many shortcuts
If I use it what's the benefit?
- You know it (as noted above)
- It has line indicators for changes
- It has built-in source control
- It has a powerful editor
- It includes Markdown preview
- It's fast (when creative writing not coding)
How can I improve my workflow?
Organisation
Chapters
I tend to write in Markdown with one file per chapter. This provides clear separation, simple and obvious commits in source control, and relatively distraction-free writing as I'm focused purely on the chapter I'm working on.
My current tooling is custom and handles these multiple files by reading a YAML file that specifies the sequence of the chapters and stitching it together on-demand. You can replicate this quite easily with a simple batch file that, when run, joins the chapters into a single long document (you just need to remember to keep the commands in the batch file up to date).
_combine.bat:
type Introduction.md > _book.md
type Hero-enters-the-frame.md >> _book.md
type Villain-steals-stuff.md >> _book.md
The use of a single >
on the first line is deliberate to ensure you don't continually build up the book with repeated copies appended over and over.
Books and drafts/proofs
Every book is a Solution - choose to create a Blank Solution from the Other project types dropdown.
Within that solution every version is a Project. There's no such thing as an empty project, so create a Console one (not the Framework version) and remove
Program.cs
. The project won't build, but then it'll never need to so that's not a problem.
\My-Amazing-Book
My-Amazing-Book.sln
\01-first-draft
_combine.bat
_book.md
01-first-draft.csproj
Introduction.md
Hero-enters-the-frame.md
\02-second-draft
_combine.bat
_book.md
02-second-draft.csproj
Introduction.md
Hero-enters-the-frame.md
Obviously you could do everything in a single project and use source control (tags, branches etc) to identify particular drafts, but the advantage of the above is that regardless of how far down the road you've gone you can still refer to previous drafts without needing to mess around with commits.
In effect you can flip between and compare multiple drafts side-by-side without context switching into source control (and you still get the commit diffs if you need them).
Plugins
Visual Studio already supports Markdown preview. However the Markdown Editor 2 extention by Mads Kristensen provides a couple of extras that really help.
- A navigation dropdown that lets you jump around a document based on the headings
- Drag/drop images and file links
- Highlighted errors in links or the heading hierarchy
- Automatically synced Markdown preview
- Customisable theming of the Markdown preview pane
For theming you can create an md-styles.css
file either in your solution folder or in the folder above it. If you do the latter then your solution and all solutions sat alongside it gain the same theming.
md-styles.css:
/*
Custom styling for the Markdown 2 Visual Studio extention.
Place in a folder above the one containing repos.
MUST be named `md-styles.css` to be picked up.
*/
html, .markdown-body {
background: #fcfcfc;
color: #111;
cursor: default;
}
.markdown-body {
padding: 1rem 2rem;
font-family: 'iA Writer Duospace', verdana, tahoma, arial, sans-serif;
font-size: 13pt;
line-height: 135%;
}
h1, h2, h3, h4, h5, h6 {
line-height: 130%;
letter-spacing: -1px;
}
code {
background: #ddd;
padding: 0.1em 0.3em;
}
a {
color: #44b;
text-decoration: none;
border-bottom-style: solid;
border-bottom-width: 2px;
}
li {
margin-top: 0.4rem;
margin-bottom: 0.4rem;
}
@media (prefers-color-scheme: dark) {
html, .markdown-body {
background: #222;
color: #fcfcfc;
}
code {
background: #444;
}
a {
color: #6ec9ff;
}
}
I should point out that the colours in the CSS above switch according to the OS choice of light/dark theme. The extention has it's own light/dark setting, but if you use the media selector above then the OS one will always override it so you may as well leave the extention set to automatic.
Other tools
For source control alongside the majority of developers I use Git. For repos at various times I've use Github and Gitlab, plus self-hosted Gitea.
What I'd really recommend regardless of your choice of source control is Git Extentions. It's a great way of handling your source control, viewing commit history and branches, and much more. Having used various other source control UIs (Visual Studio and JetBrains built-in ones, SourceTree, GitKraken, and more) this one has been my standard for years now. But switch the fonts to something like Consolas 12pt for best results!
The result
Familiar editing alongside navigation, previews, theming, organisation, and source control.
Visual Studio has a notable memory overhead (usually around 1,500 MB vs 500 MB for VS Code or 20 MB for NotePad++). But when you're creative writing that memory is usually just sat there unused anyway, so for most machines with at least 8GB of RAM it doesn't matter. And if you're not coding then Visual Studio isn't as bad on battery life as you might expect.
Incidentally, NotePad++ is an excellent writing tool for Markdown apart from its previewing and navigation support - there are things you can do with plugins or functions definitions, but it's a little clunky.