Formatting Code with Visual LISP

AutoCAD AutoLISP & Visual LISP

 
Formatting Code with Visual LISP
 
 
 

The VLISP code formatter arranges the text of AutoLISP expressions in a style that improves text appearance and readability. The code formatter includes a Smart Indent feature to arrange the indentation of program code automatically. The code formatter works automatically as you enter code in a VLISP text editor window. You can also explicitly invoke the formatter to rearrange selected blocks of text or all text in a VLISP editor window. This is useful for formatting text you copy from other editors, or for reformatting your code in a different style.

To format text in an active editor window

  1. To format all the code in the window, choose Tools Format code in Editor from the VLISP menu, or click the Format Edit window button on the Tools toolbar.

  2. To format only part of the code in the editor window, select a fragment of code text and choose Format Code In Selection from the Tools menu, or click the Format Selection button on the Tools toolbar.

If you select text to be formatted, the selection must contain valid AutoLISP expressions or the formatter will issue an error message.

If the formatter finds unbalanced parentheses in your code, an alert box is displayed. Choose Yes to have VLISP add parentheses where it thinks they belong; choose No if you want to fix the parentheses on your own.

NoteThe VLISP formatter can balance the number of parentheses but usually does not insert the additional parentheses in the right places. See Checking the Balance of Parentheses for more information on detecting and correcting unmatched parentheses.

The VLISP Smart Indent feature works in the background as you type in the text editor. The indent is evaluated up to the current AutoLISP parenthesis nesting level. If the current expression is preceded by only a sequence of completed top-level AutoLISP expressions, the indentation will be zero. You can affect the amount of indentation by specifying Visual LISP format options; see the next two topics.