The Blue Horse, my debut novel which is published tomorrow, still sits, in its earliest form, in a folder on my desktop.

It is simply entitled A Novel.

When I typed that title, of course, it was not yet a novel. The title was written in hope. Inside the folder is 4000 words of feverish prose. Reading it now the manuscript has been completed and re-written, and written and re-written again, and typeset and edited and fiddled with and editorially caressed and lovingly printed, is interesting and a little amusing. It is also comforting: this collection of words has come a long way since those first sentences were written. But, at least, the first sentence I typed, in 2010, remains the same : "George Newhouse was in love with his wife. But his wife was dead."

Since that beginning, I have lost a lot of hair, and I have become a father of two boys. I began to write George's adventures when Hope, my wife, was pregnant with our oldest son. I remember thinking, during one sleepless night after his birth: "My novel will never be finished."

But those sleepless nights passed. I found time to write. Indeed, I wrote the novel mainly at night. The bulk of the novel, which in its first draft was more than 90,000 words long, was mostly written between 9pm and 2am. The darkness may have played a part in the penumbral gloom of the narrative, but I suspect not - it was always going to be fairly bleak. I had decided, after all, to write about loss and recovery, about memories and nightmares, and - through a warped eyeglass - Scottish art and society.

I also wrote in fragments of snatched time: in my reporter's notebook on trains, on my laptop on planes. Slowly and haltingly, the story came together. Writing this way, in bits and scraps, I often lost the threads of its plot strands and confounded myself. Other times, the narrative lurched as I discovered another painting, or theory, I wanted to somehow address. Its tone and atmosphere became frazzled and inconsistent.

The Blue Horse is actually my third attempt at a novel. I first tried to write a novel in the early-2000s. Giles Gordon, the late literary agent, read its first chapters. He said the book resembled a "Jacobean slaughterhouse". But he still encouraged me to write on and "find my voice".

So I began writing an anonymous blog online. I also read other writers even more intently. I spent most of my spare time from around 2002 to 2007 writing short stories and poetry. Some of those stories and poems are now published. I even managed to entice an agent, Mark 'Stan' Stanton, to try and sell a collection of these short stories. But no one was interested.

Smarting, I wrote, quickly, in about a year, my first novel. It is called Black Metal. Stan said it was a "fine novel" . But, using the words that have quietly knifed so many aspiring writers' dreams, it was "too quiet". That is: boring. It sits silent, largely unread, in a desktop folder, next to A Novel.

I immediately set to work on another. I wrote its early chapters with a kind of unhinged and sleep-deprived fervour. The Blue Horse was determined not to be "too quiet": Newhouse engages in lot of disastrous albeit colourful sex. There was blood and drugs. There was mental disintegration and secret Edinburgh orgies. That first draft was harsh and jagged and, it must be said, unpalatable to nearly everyone I sent it to, both agents and publishers.

Very luckily for me, the Glasgow-based publisher Freight Books, was willing to read my writing. In 2013, Adrian Searle, who runs Freight, was intrigued enough to read the first draft. He said, albeit kindly, that it was "unpublishable". But he recommended that I work with an excellent freelance editor called Helen Sedgwick. She is now managing director of Cargo Publishing. Her editorial notes were key in transforming that erratic first draft. Her praise was welcome and her criticism painfully correct ("All this character does is clean and give blowjobs," she noted in a margin). Working with Helen, The Blue Horse was emerging in sleeker form. Its occult heart began to beat more strongly. My wife and friends read it and gave me more encouragement and notes.

As a journalist, however, I was used to being impatient, writing fast copy, the copy being edited with (usually) minimal changes, and being almost instantly published. Writing a novel is very different. It requires patience, repetition and a little fortitude. However, in late 2013, Adrian and I met again for a coffee and he said what I had never really thought I would ever hear: "We want to publish your novel."

Then some really hard work began. Rodge Glass, the writer, editor and teacher, was appointed by Freight to editorially guide The Blue Horse to its published form. Most of my spare time in 2014, then, was spent going through two further re-writes. This was an intermittently painful operation. The book had some unresolved problems. The Blue Horse was still over-written. A lot of prose was culled. Rodge is an assiduous editor. We did not agree on everything, but everything he pointed out was worth attending to. He has a good sense of pace and structure, and that was absolutely key.

I emerged from the editing process encouraged. The final edits, both with Rodge and with the tireless Robbie Guillory at Freight, were minimal. Lovely things began to happen: it was typeset, and a great cover was designed. Now, A Novel is ready to be published as The Blue Horse. And it is as good as it could be.

And I have opened another folder on my desktop: it is entitled Another Novel.

Read The Herald's review of The Blue Horse next Saturday