The ideal time horizon to hold a stock is forever. When you let the magic of compound interest do its thing and own a slice of a quality business for many decades, you can easily see a return of 10 or even 100 times your initial investment. But which stocks are ideal to buy and hold forever? Personally, I look for businesses that have strong management teams, have strong track records of creating value for shareholders, and are trading at reasonable valuations.

Here are two stocks that fit those criteria that you'll regret not buying in 2022 and holding forever.

A person pointing to a line chart moving up and to the right.

Image source: Getty Images.

1. Autodesk: software for design and simulation

Autodesk (ADSK 0.92%) owns a collection of software products that serve the engineering, architecture, and construction industries. Its most important program is Revit, which is 3D design software for architects that follows building information modeling (BIM) regulations.

The BIM aspect is important because governments around the globe are mandating that architecture and construction firms follow BIM standards, which is driving demand for BIM-related design software. Revit has the majority market share within BIM design software, which is a durable tailwind that should increase demand for the product over the next decade and drive Autodesk's top-line revenue growth as well.

Other important segments for Autodesk include AutoCAD (its original design software from the 1980s that is still cooking today), Fusion 360 (mechanical and manufacturing cloud-based design), and the Autodesk Construction Cloud (workflow tools for construction companies). And you can learn about its many other products on the company's product page.

As with Revit and BIM, there is a rising demand in all industries to digitize and make 3D models so industrial processes are more efficient. This broad tailwind should boost underlying demand for Autodesk's software programs over the next decade and beyond.

In the mid-2010s, Autodesk made a transition from selling up-front licenses for its various software programs to a subscription model in which individuals/companies pay a recurring fee to access its software. This has helped stabilize and grow its customer base. At the close of Autodesk's fiscal year 2022 (which ended in January), it had 6 million total subscriptions across its various business units, which translated into $4.39 billion in annual revenue and $1.48 billion in free cash flow.

Next fiscal year, Autodesk expects to generate just north of $5 billion in revenue and $2.17 billion in free cash flow. With a current market cap of $48.4 billion, that gives the company's stock a forward price-to-free cash flow (P/FCF) ratio of 22.3 if it can hit the midpoint of its guidance. Given the ongoing marketability of its design and engineering software, management's track record of creating value for shareholders (the stock is up more than 10 times in the last 20 years), and a reasonable P/FCF, now looks like a perfect time to buy shares of Autodesk and hold them for a long, long time.

2. Nelnet: more than just student loans

Unlike Autodesk, which focuses on serving a few specific industries, Nelnet (NNI 0.75%) is a wide-ranging conglomerate with its fingers in many different pies. The company started out originating and repackaging student loans for the federal government in the 1990s. However, it was required to stop originating new loans when the government took the business entirely in-house in 2010. Since then, it has taken the cash flow from its existing loan book and reinvested it in various industries.

Today, Nelnet's remaining loan book will generate approximately $2 billion over the next decade-plus. It also operates Nelnet Bank, a student loan servicing business, and an education technology business. Various other investments include real estate, renewable energy projects, its stake in Allo communications (a broadband provider), and a venture capital portfolio and are valued at $1.6 billion right now.

What attracts me the most to Nelnet is its track record of compounding book value per share (including dividends) since it went public. This metric measures growth in book value, or assets minus liabilities, which is the best measure for valuing a financial/investment company like Nelnet. Since 2004, Nelnet has compounded book value per share at 17.2% a year, which is even more impressive when you consider its core business model got disrupted in 2010.

As of this writing, you can purchase shares of Nelnet at a market cap of $3.3 billion, or for less than the future cash flow coming from the loan book and the $1.6 billion in investments held on the balance sheet. And that doesn't include loan servicing or education technology, two companies that each generated around $50 million in operating income last year.

With the historical growth in book value per share and an opportunity to buy this collection of assets at such a discount, I think now is a great time to buy Nelnet stock and hold it for the long haul.