you should use /var instead of /set so you don't need to unset it
the first 2 if statements are unneeded as $replace($1-,$chr(32),+) will only change the space character and not any other
else if ($1 == $null) { echo nothing entered, halting } { halt }
should be
else if ($1 == $null) { echo nothing entered, halting | halt }
but the halt is redundant.
alias yt {
var %ytsearch = $replace($1-,$chr(32),+)
if (%ytsearch) { run http://www.youtube.com/results?search_query= $+ %ytsearch }
else { echo -a nothing entered, halting }
}
is a simpler way to do it