11

On MacOS I see ways to enter checklists and tables but no way to enter a horizontal line. Is this possible to do?

8

I'd like to see this as an actual formatting option too… but it seems unlikely to come any time soon. Experimenting with various Unicode line characters (like ) or a series of em dashes (opt + shift + dash) is not a great solution as the width of the "line" doesn't change with the width of the note window. And if you squeeze the window width narrower than your faux line, it will wrap. Ugh!

Here's the best workaround I've come up with (it ain't perfect, but it works for me!):

  1. In Photoshop (or similar), make a new document of somewhere in the neighborhood of 2400 pixels wide by 6 pixels high.

  2. Fill it with black.

  3. Save as a .jpg (or .gif, or .png… it doesn't really matter) in a place that you'll have easy access to, like your Desktop.

  4. In Notes, put the cursor on a new line where you would want the horizontal line to go.

  5. Click to select the file you saved to your desktop, and copy it to your clipboard (command + c).

  6. Head back to Notes and paste it in (command + v). You'll end up with something like this:

horizontal lines

What's nice here is as you adjust the width of the window, the horizontal line image will always span the full width:

full width

You'll notice that the height of the line also changes proportionally with the window width… so you'll have to experiment with a size that works for you. 2400 x 6 seems to work for me. Here's a link to the file that I'm using, if you want to give it a try (right-click to download):

https://i.imgur.com/bcnfe7K.jpg


BONUS PRO TIP: If you're using TextExpander (or similar) make a new snippet that inserts this line graphic so you don't have to do steps 5 and 6 (above) every time. I've got mine set to -----. Adding the horizontal line with this shortcut has become second nature.


If you do not have TextExpander (or similar) to make a new snippet that inserts this line graphic so you don't have to do steps 5 and 6 above, you can create an Automator service as shown in the image below using the following example AppleScript code:

property hLine : (path to pictures folder as string) & "hLine.jpg"

set the clipboard to (read (hLine as alias) as JPEG picture)
delay 1
tell application "System Events" to keystroke "v" using command down
  • As coded, the linked "bcnfe7K.jpg" was saved in the Pictures folder within the Home folder as "hLine.jpg", so adjust it in the example AppleScript code as necessary.

Automator Service

Then assign it a keyboard shortcut, as in the image below, I used ⌘L as it was not assigned in Notes.

Keyboard Shortcut

Now to insert the horizontal line in Notes, set the cursor where you want the line and press: ⌘L


Note: The example AppleScript code is just that and does not employ any error handling and is meant only to show one of many ways accomplish a task. The onus is always upon the User to add/use appropriate error handling as needed/wanted.

  • 1
    I added an Automator Service to your answer, which by the way is an excellent answer. +1 – user3439894 Feb 26 '18 at 15:32
  • Wish I could upvote this more than once – Zaki Aziz Feb 26 '18 at 18:25
  • @Xecure True, you can only upvote once… but you can still mark it as the solution. wink – Sam Feb 26 '18 at 19:38
  • @Xecure, While you can only up vote a question once, you can also choose to click the check mark thus making this the accepted answer, if you so choose. – user3439894 Feb 26 '18 at 20:22
  • Bonus points go to whomever can get something like this working on iOS! – Sam Feb 27 '18 at 2:11
5

There is a solution to add a horizontal line by just using a keyboard shortcut that triggers Automator to type a line of underscores for you. It works well, and it would be great if the keystroke animations were removed when pressing the shortcut!

Check this brilliant answer at macrumors.com by chown33 (note that the steps below were written for OS X 10.8.4 Mountain Lion so test it accordingly):

The main phases of a solution are:

  1. Make a Service in Automator that types '_' your desired number of times.
  2. Assign a Keyboard Shortcut to the Service using System Preferences.
  3. Test it.

Phase 1 : Make a Service in Automator

  1. Launch Automator.app.
  2. Choose "Service" from the "Choose a type for your document" dialog.
  3. Add a "Run AppleScript" action to the workflow.
  4. Paste the following AppleScript into the action: Code:

    tell app "System Events" to keystroke "_______________________"
    

    The pasted-in AppleScript should completely replace the template AppleScript that automatically appears in the "Run AppleScript" action. That means you click in the box of the action, choose Select All from the Edit menu (⌘A), then delete everything. Optional: you can increase the length of the __ string.

  5. At the top of the workflow, set the popups to show: Service receives no input in any application
  6. Save the Service (⌘S), and give it a name.

Phase 2 : Assign a Keyboard Shortcut in System Preferences

  1. Launch System Preferences.
  2. Choose the Keyboard pane, then click the Keyboard Shortcuts tab.
  3. Two side-by-side lists will appear.
  4. Choose Services in the left-hand list. The right-hand list will show the available Services.
  5. Scroll down the list until you see the name you gave your Service. It will probably be under the General heading.
  6. Ensure your service's checkbox is checked.
  7. Click its "add shortcut" button, then press your desired key combination to assign it a keyboard shortcut (the key combination must be unique).

Phase 3 : Test it

  1. Launch Mail.app.
  2. Click the Mail menu, then move down to the Services hierarchical menu.
  3. Does your named Service appear in the menu items?
  4. Does your named Service have its assigned keyboard shortcut?
  5. Create a new message (⌘N).
  6. Click in the body of the new empty message.
  7. Press the keyboard shortcut.
  8. Is the series of _'s correctly added to the message?
4

Hold down the hyphen key on the keyboard. When you let off, the dashes will draw in as a solid line.

2

I find myself often needing to write a date before the divider line. Inspired by @Muthu's answer, I made the following Applescript:

on run {input, parameters}
    set _Date to short date string of (current date)
    tell application "System Events"
        keystroke _Date
        keystroke return
        keystroke "-------------------------------------------------------"
        keystroke return        
    end tell
end run

Assigning this service a shortcut, it outputs something like:

2019-04-07
-------------------------------------------------------

You can define the line as long as you want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .