It's sometimes tough to admit, but not every stock an investor is holding is always a true long-term investment. Sometimes, they're short-term trades masquerading as investments, inspired by circumstances that won't last.

This misstep is understandably easy to take. It's difficult to see into the distant future, after all, even though that's the time frame we should all bear in mind when picking a stock.

With that as the backdrop, here's a rundown of three great names anyone can be comfortable buying and holding for the next 20 years. They should be held that long, in fact, to ensure we get the maximum potential out of them despite the occasional stumble we're sure to see between now and then.

A long-term, multidecade timeline marked by push pins.

Image source: Getty Images.

1. Walmart

Walmart (WMT -0.12%) is of course the world's biggest brick-and-mortar retailer, operating more than 5,000 stores in the United States and another 5,000-plus outside of the U.S.

In a world where Amazon exists at the same time Target, Kroger, and millions of other smaller retailers are looking to reclaim past and future business that Walmart and Amazon both took from them, the retailer looks vulnerable. It's also subject to the pitfalls of its sheer size; big companies are tough to manage.

This is not yesteryear's Walmart, however.

It's difficult to see from a distance with just a passing glance, but Walmart is evolving. It's no longer just a mere place to go buy stuff you need. It's changing into a lifestyle company that caters to the things you want and how you want to live your life. Premium private-label wine, healthcare clinics, at-home technology installation services, and subscription-based delivery of online orders -- including fresh groceries -- are now all in its wheelhouse.

Moreover, consumers are responding to these initiatives. Last year's overall top line managed to improve (organically) to the tune of 1.6% despite the world easing out of the sales surge prompted by the early days of the pandemic. Same-store sales in the United States improved an incredible 6.4%, with e-commerce growing another 11% despite tough year-over-year comparisons.

Simply put, this big ship is moving in the right direction. It's moving slowly, admittedly, but once it reaches full speed, it's apt to keep moving in this direction, at that speed, for a long, long while.

2. Ford Motor Company

Ford Motor Company (F 0.74%) is like Walmart in many ways, chief among them its current reinvention effort. Management knows it can no longer be a mere car company. It has to become a lifestyle company as well, in the people-transportation and mobility business, and whatever that entails.

Sure, autonomous vehicles and urban transit are part of this effort. Perhaps the biggest forward-thinking initiative Ford is finally taking on, however, is electric vehicles. The company has earmarked $50 billion to invest in the planning and production of battery-powered cars and aims for half of the cars it's making by 2030 to be electric vehicles. One has to assume it's moving toward an eventual all-electric lineup.

The opportunity is certainly firm enough. The United States Energy Information Administration estimates the number of battery-powered vehicles traversing the planet will grow from around 10 million now to 672 million by 2050.

Ford shareholders won't have to wait that long to see the fruits of the company's EV labors, though. The company's all-electric pickup truck, the F-150 Lightning, was sold out before they even began being mass-produced. Demand has been so strong, in fact, that the company had to stop taking reservations for the vehicle. In the meantime, Ford's new battery-powered Mustang Mach-E has displaced the Tesla Model 3 as Consumer Reports' favorite EV for 2022.

3. Microsoft

Finally, add Microsoft (MSFT 0.80%) to your list of great stocks to buy and hold for the next 20 years.

There was a time when such a long-term commitment to this company couldn't be comfortably made. Microsoft's hold on the PC market was threatened by the advent of mobile devices and open-source operating systems like Linux. Indeed, according to data from Global Stats' statcounter, Windows' share of all the world's computing devices has been pared back from 81% to 31% over the course of the past 10 years, as more consumers buy devices powered by Android and Apple's iOS.

There's an important detail obscured by this shifting market share, however: Windows itself isn't even meant to be a major profit center anymore. It's more of a means to an end to other, bigger, and more reliable (and recurring) revenue.

Microsoft Office is a prime example of the new business model. While still offered as a one-time purchase, many consumers and corporations prefer to "rent" access to cloud-based versions of the productivity software. To this end, the number of Office 365 subscribers now stands at 56.4 million, with each of them paying between $6 and $12 per month for the service, month in and month out.

And it's not just Office 365 for at-home and at-work use. The company's cloud computing software, Azure, is also available on a subscription basis. Its revenue grew 46% last quarter, driving the lion's share of the Intelligent Cloud division's $18.3 billion worth of business for the three-month stretch.

LinkedIn and Xbox are two other platforms that generate reliable recurring revenue. And while you typically don't realize it, Microsoft is doing a great deal of work for small businesses. It's also the name behind surprisingly still-relevant search engine Bing.

These are products and services that are still going to be needed 20 years from now.