Matching Parentheses

AutoCAD Visual LISP

 
Matching Parentheses
 
 
 

VLISP provides a parenthesis matching feature to help you find the close parenthesis that corresponds to an open parenthesis.

To match an open parenthesis with its corresponding close parenthesis

  1. Place your cursor in front of the opening parenthesis that precedes the setq function call.
  2. Press CTRL + SHIFT + ]. (Double-clicking also does the trick.)

VLISP finds the closing parenthesis that matches the one you chose, and selects all the code in between. Not only does this ensure you typed in the correct number of parentheses, it also makes it easy to copy or cut the selected text. This might have come in handy when you updated this call at the end of Lesson 4.

Why else might you want to do this? You can copy some code to the VLISP Console window, paste it there, and try it out. Or maybe you have figured out how to replace 50 lines of code with three really marvelous lines of much better code. You can quickly select the old code using the parentheses matching tool, then eliminate it with a single keystroke. It is a lot quicker to let VLISP find an entire block than for you to hunt down every last closing parenthesis.

There is a corresponding key command for matching and selecting backward. To try this, put your cursor after a closing parenthesis, then either double-click or press CTRL +SHIFT +[. VLISP searches for the corresponding opening parenthesis, and selects it along with the enclosed code.

Both commands are also available by choosing Edit Parentheses Matching from the VLISP menu.