Taking control of your command line history

Taking control of your command line history

Thanks to Kean Walmsley’s post on his Through the Interface blog, I have learned something that would have been handy to know for the last decade or so, but which somehow escaped my knowledge. I learned how to increase the size of AutoCAD’s command line history cache. It defaults to 400 lines, which isn’t enough for me. I think this information deserves a wider audience than the ubergeek developers who frequent Kean’s blog, so here goes.

Although it’s not directly mentioned on Kean’s post, you can find the current command line history cache length setting like this:

(getenv "CmdHistLines")

This will return a value showing the number of command lines AutoCAD remembers, e.g. “400”. Although this is used as an integer value, it is passed to and from the Registry as a string. You can set a new value as shown below. Again, use a string, and note that values outside the range 25 to 2048 will be ignored:

(setenv "CmdHistLines" "2048")

Also, if you don’t like AutoCAD repeatedly stopping during a long listing (e.g. SETVAR ? *), you can turn off that feature by setting the QAFLAGS system variable to 2. Don’t set it to 8191 as suggested in Kean’s post, because that will change a lot of other settings, few of which are documented publicly.


  1. I know you are aware of this Steve, but maybe to help others…?

    If things start going haywire for you after you mess with QAFLAGS, set it back to 0 and try again. I frequently keep mine set to 3 and equal as frequently forget about this setting when strange things start happening…

    Here is a list of some of the things I’ve experienced/compiled from others..


  2. Edit: this comment is a reply to a non-obvious spam comment, now removed; cadlearning blogspot is now on my permanent brownlist. However, the following information is useful, so I’ll leave it in.

    Both CmdHistLines and QAFLAGS will work on all recent AutoCAD releases. I’ve tested CmdHistLines back to 2004, but I suspect it works back to Release 14. QAFLAGS 2 works all the way back to Release 12. AutoCAD 2007 shouldn’t be a problem.

  3. Andre

    I am trying to list all variables and be able to scroll-up to first on the list.
    Tried to Regedit cmdhistlines and it is nowhere to be found, and tried at command line with (setenv “CmdHistLines” “2048”).

    None of them worked.

    Anyone with the same issue in CAd 2012?

  4. Frank

    OK. That worked, typing it in by hand.
    Seems as though the Capital Letters matter, too.
    Now I have forgotten why I wanted to go so far back in CmdHist in the first place.
    Going to add the setenv to my 250+ combined commands (pgp file on steroids) acaddoc.lsp file!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.