Hide_and_Show_Notes

This script will toggle between hiding and showing notes, with or without a search query applied first. A note will not hide in three circumstances: a task or project is indented under the note; the note is a descendant in a search query that ends in +d ; or (occasionally) the note is the last entry in a document.

The latest version of the script can be found here. Put it into TaskPaper's scripts folder and assign it a keyboard short cut in the Keyboard and Mouse Preferences pane.

(* Hide & Show Notes
 Version 3  Preserves blank lines between entries when notes are hidden 
*)
tell application "TaskPaper"
    set z1 to "content =\"\" or type != note"
    set z2 to "(content =\"\" or type != note) and "
    set _lz2 to count characters of z2
    tell front document
        set x to search field string
        set _lx to count characters of x
        if x is not "" then
            if (x begins with z2)  then
                set search field string to (rich text (_lz2 + 1) thru _lx) of x as rich text
            else
                if (x begins with z1) and not (x begins with z2) then
                    set search field string to ""
                else
                    set search field string to z2 & x
                end if
            end if
        else
            set search field string to z1
        end if
    end tell
end tell