Heading

This is some text inside of a div block.
This is some text inside of a div block.
This is some text inside of a div block.
min read

Go to an empty paragraph

Word • Macros • Navigation
Peter Ronhovde
14
min read

Writing and editing a novel is a lengthy endeavor, so any tools that can hasten the process while being simple to use are a welcome addition. Toward this goal, we create a pair of macros to jump to a nearby empty paragraph, so we can start typing immediately.

Thanks for your interest

This content is part of a paid plan.

Go to an empty paragraph

Clicking around with the mouse is generally slower than it feels compared to using the keyboard. If you're like me, you're bouncing around a document writing, making quick nearby edits, inserting notes, etc. I wish my writing process were more organized than it is, but it's a reality for me. The ideas pop into my head, and I gotta record them or risk forgetting them. Accepting my process with a sigh, a few targeted navigation macros help the work move along faster.

These macros add another little tool to jump to a nearby empty or incomplete paragraph. I created these macros on a whim one day, but I now use their grown-up siblings often when writing or editing.

Why would we jump to an empty paragraph?

Why? It's just fast when you need it.

Perhaps this macro is more applicable to my writing style where text and notes are often entered into a growing and tentative novel outline as opposed to being hammered in from above. I develop scenes and flesh out the notes intermittently as the ideas flow. Obviously, I eventually need to fill in connecting scenes, but to my chagrin, this fluid process is how I write.

More specifically when I’m working in a novel, I'll sometimes think of a note or addition in a nearby scene. Rather than write it on paper or a separate notes document, I'll often just jump to that location and make the change, tweak some text, or add the note to the budding scene. It may be a dialog snippet or just a note to remember when I write the full scene text. Getting back to where I was working could be a clicky-tappy thing, or … I could just tap Command+Control+Space (or Control+Space in Windows) and jump back to the paragraph I was working on.

This macro has a set of specific use cases depending on how far away I jumped, but I've enjoyed using it when needed. Here is an example.

Example of jumping to the next empty paragraph
Example of jumping to the next empty paragraph

Its big brother extends the idea to incomplete paragraphs which syncs well with the idea of using it for quick, in-progress writing.

What about the “goto last edit” shortcut?

Yeah, Word includes a "GoTo last edit" feature, and it's useful on occasion, but …

Technically Shift+F5 will cycle between the last several edits. The concept is intriguing, but in practice, it's only useful in isolated circumstances because it often counts individual characters as distinct “edits.” Basically, any significant text changes before trying to jump back to the previous edit location, such as typing a single word, will confuse it.

We can’t improve this feature's behavior at the macro level since macros only know the state of the document for the fraction of a second they're running, but we can create some targeted tools to help us navigate our documents faster.

Create the empty macro

A previous post covers creating an empty macro by recording or using the macro dialog. When you’re done, you’ll have two macro skeletons something like:

Sub GotoNextEmptyParagraph()
' Jump to the next empty paragraph in the document

End Sub
Sub GotoPreviousEmptyParagraph()
' Jump to the previous empty paragraph in the document

End Sub

One jumps to the next and the other jumps to the previous empty paragraph in the document. This is necessary since we cannot assign shortcuts to macros that include any parameters.

The single quote tells VBA the rest of the text on that line is a comment meant for human readers. It's common to include an initial comment at the top of the macro briefly explaining what the macro does, particularly if any special cases exist. We start our macro steps on the empty line.

Using Find (a simple introduction)

So how do we find the next empty paragraph?

We need the Find method of the Selection (a Range variable can also use Find). Strangely, Find is listed as a property of the Selection meaning it is supposedly more like data or information about the thing, but it carries out an action like a method.

Find is its own object thingy with properties defining the search parameters, but a few methods also exist to carry out some Find-related tasks like Executing the search. These correspond to all the options we see in the regular or advanced Find dialogs in the Word application. Most settings will stay the same between searches, so we’ll stick with a more modest set of search options for this macro.

Executing the find operation

We reference the Selection's Find method like so:

Selection.Find ' Not done ...

The actual find operation is performed by referencing the Execute method.

Selection.Find.Execute

It's a little harshly named, but we're on the more peaceful side of the definition. Carry out an instruction.

Search options can be set directly within the Execute command as comma-separated options or separately by referring to the Find properties.

What are we searching for?

We set the search text using the command's FindText option.

Selection.Find.Execute FindText:="Some search text"

The colon equals := symbols is used to assign any option values needed for VBA commands. Most text is included in double quotes when used as arguments in VBA, but some exceptions exist for special characters which we will need later. As used in this example, Find only searches for plain text without any formatting. Including any formatting is a more complicated search which is outside the scope of this article.

How do we find an empty paragraph?

Think about what marks an empty paragraph in a Word document … no text, just a paragraph break.

On paper, we just skip to the next line and start writing. In Word we tap the Return key, but the document needs to mark the paragraph break somehow. A paragraph marker is a special character in Word. In VBA, we can’t put it inside double quotes like "abc" by tapping the Return key since the VBA editor would literally insert a new line. Instead, we need the Word constant vbCr as defined in a miscellaneous Word constants table.

A regular paragraph contains some text between two paragraph markers, so we’ll look for two paragraph markers side by side in the document. Yep, not one, but two side by side. Searching for two of them together would look like:

Selection.Find.Execute FindText:=vbCr + vbCr

Since vbCr is a text character, we can just “add” (called concatenate when working with text) two of them together to define the desired search text. This leans on how we use a plus sign to add numbers as in 1 + 2 = 3. Except with text (called "strings"), it jams the two strings together into a longer one.

Collapsing the selection

When we search for something in Word using the application dialog, Word automatically selects the next occurrence of the text when it is found. It works the same way in VBA. If a pair of empty paragraph markers are found, they are immediately selected.

In our use case today, we only want to position the insertion point at the empty paragraph rather than select it. We need to collapse the Selection after the search using the Collapse method.

Selection.Collapse

Collapse does exactly what the name implies. Any selected text is excluded (not deleted) from the selection with the insertion point placed by default on the left (start) of the selection.

Repositioning the cursor

Unfortunately, collapsing the Selection like this will leave us at the end of the previous paragraph relative to the empty paragraph we found. We need to move down a line to the empty paragraph using the MoveDown method.

Selection.MoveDown

The default Unit for MoveDown is by one line which is exactly what we need.

As a quick aside, even if we chose to collapse toward the end of the Selection earlier, it would place our insertion point at the beginning of the next paragraph because both paragraph markers were selected by the Find operation. The "empty" paragraph position is between the two characters, so an extra move step is necessary in either case.

What if it doesn’t find an empty paragraph?

Oh, we have to think about that?

If it doesn’t find an empty paragraph, nothing happens with the Find operation, but the following collapse and move steps are still run leaving us with an annoying side effect of moving the insertion point down a line. It's not the end of the world, but it would look odd when you’re expecting to jump to an empty paragraph somewhere later in the document.

Ughhh.

Hold on. Don't throw your keyboard out the window.

Was the search successful?

The macro should only collapse the Selection and move down a line if an empty paragraph is found. We can check for this using the Found property of Find.

Selection.Find.Found

This property has a (Boolean) value of True if latest search text was found in the document but False if the text was not found. As such, we can directly use the property in a conditional statement to make a decision about which commands to run.

Conditional check on Find Found

A rough conditional statement for this check looks something like:

If Find found the search text Then
' Move to the empty paragraph
Otherise
' Do not do anything else (just finish the macro)
End the search check

Since we do not do anything in the "otherwise" case, we can just omit that part. We convert this into its VBA equivalent (see a previous article for more explanation of VBA conditional statements).

If Selection.Find.Found Then
' Search was successful, so move to the empty paragraph
Selection.Collapse ' Since the text is selected by default
Selection.MoveDown
End If

We now only collapse the selection and move down a line if the Find step actually finds the search text.

Ignore spaces

It would be nice to catch an empty paragraph even if it contains just spaces. The above settings literally search for two paragraph markers with nothing in between them, but we could tweak the search to allow spaces. The IgnoreSpace option is a True or False (Boolean) property of the Find object thingy.

' Add search option to include any spaces between the paragraph markers
Selection.Find.IgnoreSpace = True

Combining it with the execute command, it would look something like:

' Allow search to include any spaces between the paragraph markers
Selection.Find.IgnoreSpace = True
Selection.Find.Execute FindText:=vbCr + vbCr

For regular searches, I generally turn this option off (by setting it to a False value) because I want to be specific with my search text, but it's a nice addition in this macro because it is simple, but it also fits with the advertised function. It conveniently extends the base macros to allow any spaces in an intuitively "empty" paragraph.

This value assignment uses just an equals = sign rather than a colon equals := symbol as used above for the "command-line" FindText option. I would have preferred a little more consistency, but VBA does distinguish between the two assignment types.

Technically, this option also catches any tabs or non-breaking spaces. Whitespace is supposed to include any additional paragraph markers, but the Find operation seems to omit them.

The Execute method documentation implies the IgnoreSpace can be set as an additional command option but using it that way results in an error. We must set it with the above separate statement.

What about searching backward?

Sometimes we’ll want to move backward to an empty paragraph in the document. Find searches forward by default, but it also has a Forward search property to control the direction.

' Search backward in the document
Selection.Find.Execute FindText:=vbCr + vbCr, Forward:=False

We need a comma, to separate the two options. The Forward option defaults to True (search forward in the document, of course), so we just assign a False value to it to search backward instead.

Any gotchas?

What could go wrong?

Saved search parameters

If you search backward in the text and then try to use the forward version, the Find method remembers the Forward setting to be False, so it’s safer to just give the direction explicitly for both macros.

' Search forward in the document (avoid any saved search parameter issues)
Selection.Find.Execute FindText:=vbCr + vbCr, Forward:=True

In fact, it’s probably safer to give most of the related arguments for Find operations each time, but we’ll save that for the grown-up sibling macros.

What about the first paragraph of the document?

Technically, an empty first paragraph of the document is an exception to the above search condition for two paragraph markers, but we'll ignore that special case to keep things simpler. It's a less common case, and a separate standard Word shortcut exists (Command+Home in Word for Mac or Control+Home in Windows) to jump to the beginning of the document anyhow.

Search settings are sticky

Search options are saved between searches even for different macros since they are application-level settings. They will even be reflected in the Find dialog if you do a manual search afterward. However, I have omitted most search options in the macros below for simplicity.

What about other search settings?

We could be more explicit with the rest of the search options, and it's probably a good idea, but I wanted to keep this macro simple. See the improved macros for a more specific set of search options. If I had to add another extra option here just to be safe, I might clear any formatting for the search:

' Clear any formatting from the search (probably extra but safer)
Selection.Find.ClearFormatting

Most of the time, this would not be necessary since searching for specific formatting is not common, so it is omitted in the presented macros below.

Final macros

The final versions of the macros are simple with one for each direction. The macros are almost identical since the move steps after a successful search don't change.

While you might be skeptical of their practical use, I use them regularly when writing. Once you get used to them, you'll be aggravated to have to grab the mouse to move back to your working position. I sometimes take extra advantage of them by leaving an empty paragraph where I’m working, so I know I can quickly jump back to it almost immediately.

Searching forward in the document

Collecting the above commands, the forward search version is:

Sub GotoNextEmptyParagraph()
' Jump to the next empty paragraph in the document
' Allow search to include any spaces between the paragraph markers
Selection.Find.IgnoreSpace = True
Selection.Find.Execute FindText:=vbCr + vbCr, Forward:=True

' Move down to the empty paragraph if it was found
If Selection.Find.Found Then
Selection.Collapse
Selection.MoveDown
End If
End Sub

If you've come straight to the final macros, we specified the default Forward option value as True explicitly because search options are kept between searches even for different macros. We do not want a backward search to mess up the forward version.

I generally assign this macro to Command+Control+Space in Word for Mac and Control+Space in Windows.

Searching backward in the document

For the backward search, only the Forward option value changes, but we need a separate macro to assign to a shortcut because Word does not allow arguments for any macros used for a keyboard shortcut.

Sub GotoPreviousEmptyParagraph()
' Jump back to the previous empty paragraph in the document
' Allow search to include any spaces between the paragraph markers
Selection.Find.IgnoreSpace = True
Selection.Find.Execute FindText:=vbCr + vbCr, Forward:=False

' Move down to the previous empty paragraph if it was found
If Selection.Find.Found Then
Selection.Collapse
Selection.MoveDown
End If
End Sub

I assign these macros to the shortcuts Command+Control+Space in Word for Mac and Control+Option+Space in Word for Windows.

Improvements

It's not generally good to work directly with the Selection since the changes are immediately visible on the screen. In practice, these three changes probably occur literally faster than the blink of an eye.

In my own writing and editing, I sometimes start a paragraph before I think or remember a note about a nearby scene, so I tweaked my version to allow incomplete, not just empty, paragraphs.

Affiliate Links

If you're interested in using Word or another tool related to the article, check out these affiliate links. I may make a small commission if you purchase when using them, but there is no increase in cost for you, and it helps to support this site and associated content.

I've been using Microsoft for Business for commercial use (that's us writers) on one of the lower pricing tiers for years. I get to use my macros, have online storage, and don't have to worry about software updates.